Dec 18

为WordPress添加SyntaxHighlighter支持只需遵循一下步骤:

  • 为页面新增对基础文件的引用:shCore.js和shCore.css。
  • 添加合适的笔刷文件,每种语言对应一个笔刷文件。
  • 引用shCore.css和shThemeDefault.css。
  • 调用SyntaxHighlighter.all()函数,完成。
  • 具体到WordPress上,只需在主题header.php文件中的标签内加入以下代码:

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    引用时需在HTML编辑条件下使用

    
    

    即可,具体如下:

    需要高亮的代码

    我不会修改样式,只是将右边的滚动条去掉了,其余的都是使用的是官方默认的配置,我觉得默认的配置已经很好看了,不需要怎么修改了。

    Nov 14

    * IPv6 Deployment Growth

    Of the 39,570 networks in the world running BGP, the number running IPv6 has increased to 4,830, or 12.2%. This is an increase from 7.4% just one year ago or 9.5% six months back.

    The global IPv6 routing table has passed 7000 IPv6 prefixes.

    Source: http://bgp.he.net/ipv6-progress-report.cgi

    * Free Interactive Programming Tutorials

    We’ve launched an interactive programming tutorial site with beginning courses in Perl, PHP, Ruby, Python, SQL, HTML, CSS, JavaScript, jQuery, and XML. It provides a type-along style course that allows you to write and run snippets of code online
    via your web browser.  Even if you already know how to code you may find a quick review amusing and entertaining.  When you get done with that you can also post your own code snippets or exercises to the code forums for other people to run.  The site
    is in beta and just launched, please let us know what you think.

    http://code.he.net

    * Hurricane Electric Carrier Networking Event

    Hurricane Electric is hosting a carrier networking event on
    November 17th.

    If you buy long haul wavelengths or metro ethernet circuits and would like to meet carrier representatives to discuss
    telecommunications projects you are working on, or would just like to chat with other Internet Engineers, please join
    Hurricane Electric for a Carrier Networking Event.

    When: Thursday, November 17, 2011 6:00pm

    Where: Hurricane Electric’s Fremont 2 Facility
    48233 Warm Springs Blvd
    Fremont, CA 94539

    Refreshments will be served.

    Confirmed participants include:
    360networks
    CenturyLink
    Comcast
    Supermicro
    Level3
    XO Communications

    To RSVP or for more information, please contact:
    [email protected]

    * Exchange Point Connection Upgrades

    We have upgraded to 10 Gigabit Ethernet ports (10 Gbps) at the following exchanges: LONAP (London), NLIX (Amsterdam), LAIIX (Los Angeles), and MICE (Minneapolis).  In addition, we’ve added another port at the HKIX (Hong Kong) Internet Exchange Point.

    Hurricane Electric’s upgrades in Amsterdam, Hong Kong, London, Los Angeles, and Minneapolis will provide Hurricane Electric’s customers with increased throughput, reduced latency and improved reliability.

    Hurricane Electric now has over 7000 BGP sessions with over 1800 IPv4 and IPv6 networks at 45 different exchange points in North America, Europe, and Asia.


    Become a Fan on Facebook
    http://facebook.com/he.net

    Follow us on Twitter
    http://twitter.com/henet

    Hurricane Electric IPv6 Tunnel Broker Project
    http://tunnelbroker.net

    Hurricane Electric IPv6 Certification Program
    http://ipv6.he.net/certification

    Hurricane Electric Free DNS
    http://dns.he.net

    Hurricane Electric Interactive Programming Tutorials
    http://code.he.net

    Oct 30

    把 Vim 折迭(Folding)后,然后可以放入口袋?呵呵,当然不是这样啦!这是 Vim 的一个很特殊功能(原始Vi及一般的Vi clone皆无此功能)。简单的说,就是可以将文章内容,依据他的结构,把多行内容集中于其中一个代表行来显示,屏幕上只看得到章节标题那一代表行,这样整个文章结 构就一目了然,真正要阅读其他内容时,再由简单的按键或鼠标来打开。这对于不含目录结构的文件或程序代码很有用处。

    11.1 手动折迭
    折迭的行为表现是由Foldmethod[fdm] 这个设定项来控制的,这个设定项预设是manual,就是手动设定,这是本节所要叙述的最基本折迭方式。其他折迭方式会在下一节介绍,折迭的方式,其中会有互相冲突的地方,使用上请注意一下。

    11.1.1 折迭的产生
    手动产生折迭(set fdm=manual) 的指令是 zf、zF、:fo[ld],以下以例子来说明较清楚。
    zfap 将游标所在处的那个段落折迭成一行。
    zf7G 自光标所在处至全文第 7 行折迭起来。
    :3,9fold 将第 3 行至第 7 行折迭起来。
    5zF 将光标所在处起算 5 行的内容折迭起来。
    也可以将所要折迭的部份以 Shift+v 标记起来,然后按 zf 就会将标记的内容折迭起来。

    11.1.2 折迭的操作
    zo 将游标所在处的折迭打开。open。
    zc 将光标所在处已打开的内容再度折迭起来。close。
    zr 将全文的所有折迭依层次通通打开。reduce。
    zm 将全文已打开的折迭依层次通通再折迭起来。more。
    zR 作用和 zr 同,但会打开含巢状折迭(折迭中又还有折迭)的所有折迭。
    zM 作用和 zm 同,但对于巢状折迭亦有作用。
    zi 这是个切换,是折迭与不折迭指令间的切换。
    zn 打开全文的所有折迭。fold none。
    zN 这是 zn 的相对指令,回复所有的折迭。
    那这个 zn 和 zR 不是都一样吗?不是的,zR 的作用于Foldlevel 这个设定项,是控制折迭的层次,而 zn 则是作用于Foldenable 这个设定项,他是不管层次的,只有全关或全开。当然,所得到的结果有许多情形下是一样的,但里子不一样,这在写 Vim script 时得小心分辨。

    通常,光标在折迭处向左或向右移的话,折迭也会自动打开。在进入编辑模式,例如按 i 或 o,这是也会自动打开折迭。

    其他的复制、删除及替换等动作还是可以和一般正常文稿一样的操作,例如 dd 就会删掉一整个折迭,yy 会复制一整个折迭,p 会贴上一整个折迭。把整个折迭就当做是一行就行了。

    11.1.3 折迭的记忆
    手动折迭,在下一次开档时就消失了,但我们可以使用 :mkview 把折迭的情形记忆起来,下一次加载同一个档案时就可以下 :loadview, 记忆起以前折迭的情况。当然,使用手动折迭及记忆,在操作上并不是很方便,除非是把他写成 Vim script 来叫用。因此下一节要谈到自动折迭,这可能会比较实用一点。

    11.2 自动折迭
    这里比较实用的是依文件内的标志来折迭,因此其他的方式就只稍微介绍了。

    11.2.1 以缩行为依据
    :set foldmethod=indent 就会依缩行来折迭,本来预设是 :set foldmethod=normal。请注意,此时手动折迭的设定会被停止无法使用。

    11.2.2 以特殊的表示法为依据
    :set foldmethod=expr,另外还要设定 :set foldexpr=…,可参考在线使用手 册 :h fold-expr 的例子。

    11.2.3 以语法为依据
    这是在定义语法(syntax)文件时同时加入折迭的定义。然后,set foldmethod=syntax 就会依照这个语法定义文件去折迭,请 :h syn-fold。

    11.2.4 以是否更改过为依据
    这在进入 vimdiff(即 vim -d file1 file2) 时会自动进入 foldmethod=diff 的模式,因此要 diff 设定项设在同一个屏幕显示才行。以便整体的浏览。当然要自行更改默认值亦可。预设是:

    setlocal diff foldmethod=diff scrollbind nowrap foldlevel=1
    这样一来,两个档案相同的部份会折迭起来,没有折迭的部份就是有差异的地方。

    11.2.5 以文件上的标志为依据
    这是跟据文章中的标志(marker)来做折迭。这些标志,起于 {{{,止于 }}},这中间的部份会折迭起来。通常这些标志是藏在批注栏里头,例如 C 程序代码的 /* 及 */ 之间,shell script 的 # 之后,Vim script 的 ” 之后,得视程序语言的不同而定,因此一般的文章就不适合使用了。

    这些默认的标志也可以由 foldmarker 来更改,但为了文件的流通性,建议使用默认值就可以了。

    当然,一些程序代码加载时再来设定 :set foldmethod=marker 就太麻烦了,这个设定可以设在文件内,例如:

    #!/bin/sh
    # 这是一个 sh script
    # {{{
    ……
    这里是 script 内容,由 vim 打开这
    个档时,这个部份会自动折迭起来。
    ……
    # }}}
    # vim:fdm=marker:ts=2

    本文为转载,但是遗憾的是没有找到原始出处,在此仍然表示感谢。

    Oct 30

    转自:http://eric.cloud-mes.com/2011/08/25/GAE_micolog_with_Django_1.2_enable.html

    I would like to thank XuMing and his Micolog, it’s very small blog program on GAE but functional is quite complete. Micolog is a good reference source code if you are newly toGoogle App Engine. There is also someone who write a article about how to upgrade the exist Micolog from Django 0.96 to Django 1.2, the article is download is broken and still have some problem about template safe notation modify here and there.

    So I would like to contribute a modified version of Micolog v7.412 source code, which I spend quite several days to debug and merge the change both in the new github.com and old SVN on Google Code code repository, I also change/enhanced the feature as below:

    • Update tinymce editor to version 3.9.4
    • Fix IE6 can not comment bug
    • Fix sys_plugin can no load error
    • Minor change Pixel theme css
    • Add IE9 pin site feature in Pixel
    • Do some python code standard layout and import optimize
    • Allow suppress logo and other not needed copyright in admin page
    • Fix email notify in sys_plugin after upgrade to 1.2
    • Add replay via comments
    • New paging facility

    The source code is also used in this blog and seems quite stable and I hope you will like it.

    Atention:

    {{ entry.content }} change to {{ entry.content|safe }}
    {{comment.content}} change to {{comment.content|safe}}
    Oct 30

    对于Apache服务器,使用.htaccess文件可以进行很多相关网络服务访问的配置。而以下的10个技巧则专门针对WordPress所进行的设置,推荐大家参考使用:
    参考原文:10 awesome .htaccess hacks for WordPress

    1. 重定向WordPress的RSS Feed链接地址到Feedburner地址
    除了修改WP的模板文件来定制其输出的RSS Feed链接地址外,还可以使用.htaccess文件来进行设置(替换yourrssfeedlink为自己的Feedburner地址)。
    # temp redirect wordpress content feeds to feedburnerRewriteEngine on
    RewriteCond %{HTTP_USER_AGENT} !FeedBurner [NC]
    RewriteCond %{HTTP_USER_AGENT} !FeedValidator [NC]
    RewriteRule ^feed/?([_0-9a-z-]+)?/?$ http://feeds2.feedburner.com/catswhocode [R=302,NC,L]

    2. 去除WordPress分类链接中的“/category/”
    默认情况下,WordPress的分类链接显示的样式为:
    http://www.smyx.net/category/technic
    其实其中的category部分没有任何意义,如果想去掉它可以修改.htaccess文件(替换yourblog为自己的网址)。
    RewriteRule ^category/(.+)$ http://www.yourblog.com/$1 [R=301,L]

    3. 使用浏览器缓存
    可以修改.htaccess文件让访问者使用浏览器缓存来优化其访问速度。
    FileETag MTime Size
    ExpiresActive on
    ExpiresDefault “access plus 1 year”

    4. 压缩静态数据
    可以修改.htaccess文件来压缩需要访问的数据(传输后在访问端解压),从而可以减少访问流量和载入时间。
    AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/javascript text/css application/x-javascript
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4.0[678] no-gzip
    BrowserMatch bMSIE !no-gzip !gzip-only-text/html

    5. 重定向日期格式的WP Permalink链接地址为Postname格式
    如果你目前的Permalink地址为/%year%/%monthnum%/%day%/%postname%/ 的格式,那么我强烈推荐你直接使用/%postname%/ ,这样对搜索引擎要舒服得多。首先你需要在WordPress的后台设置输出的Permalinks格式为/%postname%/ 。然后修改.htaccess文件来重定向旧的链接,不然别人以前收藏你的网址都会转成404哦!(替换yourdomain为自己的网址)
    RedirectMatch 301 /([0-9]+)/([0-9]+)/([0-9]+)/(.*)$ http://www.yourdomain.com/$4

    6. 阻止没有referrer来源链接的垃圾评论
    设置.htaccess文件可以阻止大多数无Refferrer来源的垃圾评论机器人Bot Spammer。其会查询访问你网站的来源链接,然后阻止其通过wp-comments-post.php来进行垃圾评论。
    RewriteEngine On
    RewriteCond %{REQUEST_METHOD} POST
    RewriteCond %{REQUEST_URI} .wp-comments-post.php*
    RewriteCond %{HTTP_REFERER} !.*yourblog.com.* [OR]
    RewriteCond %{HTTP_USER_AGENT} ^$
    RewriteRule (.*) ^http://%{REMOTE_ADDR}/$ [R=301,L]

    7. 定制访问者跳转到维护页面
    当你进行网站升级,模板修改调试等操作时,最好让访问者临时跳转到一个声明的维护页面(和404错误页面不同),来通知网站暂时无法访问,而不是留下一片空白或者什么http bad错误。(替换maintenance.html为自己定制的维护页面网址,替换123.123.123.123为自己目前的IP地址,不然你自己访问也跳转哦)
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !/maintenance.html$
    RewriteCond %{REMOTE_ADDR} !^123.123.123.123
    RewriteRule $ /maintenance.html [R=302,L]

    8. 设置你的WordPress防盗链
    盗链是指其它网站直接使用你自己网站内的资源,从而浪费网站的流量和带宽,比如图片,上传的音乐,电影等文件。(替换mysite为自己的网址和/images/notlink.jpg为自己定制的防盗链声明图片)
    RewriteEngine On
    #Replace ?mysite.com/ with your blog url
    RewriteCond %{HTTP_REFERER} !^http://(.+.)?mysite.com/ [NC]
    RewriteCond %{HTTP_REFERER} !^$
    #Replace /images/nohotlink.jpg with your “don’t hotlink” image url
    RewriteRule .*.(jpe?g|gif|bmp|png)$ /images/nohotlink.jpg [L]

    9. 只允许自己的IP访问wp-admin
    如果你不是团队合作Blog,最好设置只有自己能够访问WP的后台。前提是你的IP不是像我一样动态的哦。(替换xx.xx.xx.xx为自己的IP地址)
    AuthUserFile /dev/null
    AuthGroupFile /dev/null
    AuthName “Example Access Control”
    AuthType Basic
    order deny,allow
    deny from all
    allow from xx.xx.xx.xx

    10. 阻止指定IP的访问
    如果你想要阻止指定IP的访问,来防止其垃圾评论,那么你可以创建自己的Backlist黑名单。(替换xx.xx.xx.xx为指定的IP地址)
    order allow,deny
    deny from 200.49.176.139
    allow from all