digitalocean.com优惠码
digitalocean.com是在美国纽约的一个vps提供商,点击下面链接注册,你能得到10美元的优惠券。
https://www.digitalocean.com/?refcode=7ca8065bcdd9
最新优惠码:目前仅需通过本站注册并激活即可获得10美元账号余额,点击注册
UBUNTUDROPLET 获得10美元账号余额。
10TOSHIP 获得10美元账号余额。
RUBYDROPLET 获得10美元账号余额。
DEPLOY2DO 获得10美元账号余额。
2014SSD 获得10美元账号余额。
HOLIDAYSSD 获得10美元账号余额。
BLACK50 获得50美元账号余额,仅限黑色星期五当天有效。
DIVEIN10 获得10美元账号余额。
SSDTWTTR 获得10美元账号余额。
OCT15FREE 获得15美元账号余额。
有问题请留言
linode vps优惠
linode vps质量不错,稳定性极强。但是没有coupon,只有推荐有返点,如果有要买linode vps的同学,请点击下面的链接购买。
https://www.linode.com/?r=66112ef58044c6990efa281cb098948ca2618768
谢谢
wordpress根据不同的用户显示不同的样式
在
wp-admin/admin-header.php
合适的地方增加如下代码
if (!is_blog_admin()) { ?> <link rel="stylesheet" id='hidemenu-css' href="<?php bloginfo('template_directory'); ?>/hidemenu.css" /> <?php } ?>
然后把hidemenu.css放在主题的目录下,编辑css
有啥别的好办法么?
微信机器人ngg显示图片的修改
水煮鱼的微信机器人不错,http://blog.wpjam.com/project/weixin-robot/
但是这个微信机器人如果你用ngg,那么显示图片会有点问题,做如下修改,会显示图片。
if(!function_exists('get_post_first_image')){ function get_post_first_image($post_content){ global $post, $wpdb; preg_match('@\\no images were found
@i', do_shortcode($post_content), $matches); if($matches){ $picture_id = $matches[1]; $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 ); return get_site_url()."/".$ngg_image->path."/thumbs/thumbs_".$ngg_image->filename; }else{ return false; } } }
有问题请留言。
元宵节快乐!
happy valentine day!
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停用后的一个解决方案
<?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 = "@\\no images were found
@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'); ?>
部分代码有问题,我是否要发布到wordpress上呢?
linux下使用imagemagick批量生成缩略图的python脚本
linux下使用imagemagick批量生成缩略图的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) >= 2: size = sys.argv[1] else: size = "400" #convert 当前目录下的所有图片 convert('.', size)