happy valentine day!

image

发表在 其他 | 留下评论

L2TP 一键安装包的一个小bug

使用l2tp的一键安装包在linode上安装vpn发现一个错误,需要将
wget http://www.openswan.org/download/openswan-2.6.24.tar.gz
tar zxvf openswan-2.6.24.tar.gz
cd openswan-2.6.24
改为
wget –no-check-certificate http://www.openswan.org/download/openswan-2.6.37.tar.gz
tar zxvf openswan-2.6.37.tar.gz
cd openswan-2.6.37

其实也不能算bug,文件不在了而已,,另外可以分段执行看结果,或者看出错信息,找问题。

发表在 原创技术文章 | 标签为 , , | 留下评论

不用ngg gallery显示singlepic图片

一个wordpress用了ngg相册,大概有2万张图片,速度慢的不行,关掉了ngg,速度就正常了,于是写了段代码,兼容ngg gallery的singlepic写法,能正常显示图片,网站速度恢复正常。
莫名其妙的插件,怎么能把速度搞这么慢。这段代码可以用作NextGEN Gallery停用后的一个解决方案
[code lang=”php”]
<?php
/*
Plugin Name: fcuk ngg gallery
Plugin URI: http://www.juyimeng.com
Description: display pic without ngg
Author: juhui
Version: 1.0
Author URI: http://www.juyimeng.com/
*/

function ngg_pic_replacer($content) {
$search = "@\\[singlepic id=(?P<id>\d+)(\s+w=(?P<width>\d+))?(\s+h=(?P<height>\d+))?(\s+float=(?P<float>\w+))?\]@i";
$content= preg_replace_callback( $search, replace_picture , $content,-1);
return $content;
}
function replace_picture($matches) {
global $post, $wpdb;
$picture_id = $matches[‘id’];
$sql="SELECT * FROM {$wpdb->prefix}ngg_pictures p left join {$wpdb->prefix}ngg_gallery g on p.galleryid=g.gid WHERE p.pid = ".
intval( $picture_id ) . " ORDER BY sortorder, pid ASC";
$ngg_image = $wpdb->get_row( $sql );
$append="";
if ($matches[‘width’]) $append.=" width=".$matches[‘width’];
if ($matches[‘height’]) $append.=" height=".$matches[‘height’];
if ($matches[‘float’]) $append.=" align=".$matches[‘float’];
return "<a href=\"/".$ngg_image->path."/".$ngg_image->filename."\"><img class=\"alignnone size-full\" alt=\"image\" ".$append.
" src=\"/".$ngg_image->path."/thumbs/thumbs_".$ngg_image->filename."\"/></a>";
}
add_filter(‘the_content’, ‘ngg_pic_replacer’);
add_filter(‘the_excerpt’, ‘ngg_pic_replacer’);
?>
[/code]
部分代码有问题,我是否要发布到wordpress上呢?

发表在 原创技术文章 | 标签为 , , | 留下评论

linux下使用imagemagick批量生成缩略图的python脚本

linux下使用imagemagick批量生成缩略图的python脚本。程序用了递归,可以查找目录下所有的图片按照一定的规则生成指定宽度的缩略图。
[code lang=”python”]#!/usr/bin/env python
# -*- coding:utf-8 -*-
#批量resize当前目录下的图片,linux测试过。
#使用imagemagick

import os, sys

iswindows = ‘win32’ in sys.platform.lower() or ‘win64’ in sys.platform.lower()
isosx = ‘darwin’ in sys.platform.lower()

def convert(dirname, size=’400*400′):

for filename in os.listdir(dirname):

if "thumbs" in filename or "cache" in filename:
continue
filename = os.path.join(dirname, filename)

if os.path.isdir(filename):
convert(filename, size)
elif filename.lower().endswith("jpg"):
tname=filename.rsplit(‘/’,1)
thumb_filename= "%s%s%s" % (tname[0],"/thumbs/thumbs_",tname[1])
cmd = "/usr/local/imagemagick/bin/convert \"%s\" -resize %s \"%s\"" % (filename, size, thumb_filename)
print "process.", filename
#print cmd
os.system(cmd)
if __name__ == "__main__":

if len(sys.argv) &gt;= 2:
size = sys.argv[1]
else:
size = "400"
#convert 当前目录下的所有图片
convert(‘.’, size)
[/code]

发表在 原创技术文章 | 标签为 , | 留下评论

香芒山

image

榴莲酥皮味道不错

image

发表在 日记图片 | 留下评论

水博园一日游

image

image

image

image

image

image

image

发表在 日记图片 | 留下评论

贝贝的新作品

image

image

image

image

image

image

发表在 家庭日志, 日记图片 | 留下评论

穷人的孩子早当家

image

image

image

image

发表在 幸福生活, 日记图片 | 留下评论

试用加速了cdn

测试一下免费的cdn,看效果如何。
你访问本网站速度如何?
ping www.juyimeng.com
的ip地址是啥?

发表在 日记图片 | 留下评论

跑马拉松的26个建议

  马拉松赛事前一个月,开始进入训练关键期,这里有你应该知道的一切。

  如果你打算近期跑马拉松,并且深感不安,放心吧,我们这里有给你的忠告:提前一个月做什么,提前一个星期该如何,甚至比赛当天。关于鞋的建议?有。碳水化合物计划,也有。减量训练方案?没错。就算你不打算近期跑马拉松,我们也有理由相信,不久后就会有这么一天。所以,把这些建议放在你能找到的地方吧——它们不仅绝对正确,而且不受时间限制。
继续阅读

发表在 其他, 幸福生活 | 标签为 , | 留下评论