Category: IT

Smart Archives 增强

安装了 Justin Blanton 开发的 smart archives 插件, 发现这个插件对中文和韩文支持不佳。我给做了点小修改,并且对他的一些小缺陷也进行了补正。最后的效果请看 http://www.doyj.com/archives/

安装方法如下:
  1. 将下面的代码拷贝并存成文件smartarchives.php
  2. 将smartarchives.php 上载到你的plugin目录
  3. 到控制面板激活Smart Archives 插件
  4. 在适当的地方插入smartArchives()函数调用。
    这个函数有两个参数,第一个在”both”, “block”,”list”中选择,默认为both 第二个是要排除的分类id.
下面就是修改后的代码:
  1. <?php
  2. /*
  3. Plugin Name: Smart Archives
  4. Version: 1.5
  5. Plugin URI: http://justinblanton.com/projects/smartarchives/
  6. Description: A simple, clean, and future-proof way to present your archives.
  7. Author: Justin Blanton
  8. Author URI: http://justinblanton.com
  9. */
  10.  
  11. function smartArchives($format='both', $catID='') {
  12.  
  13. global $tableposts, $wpdb, $PHP_SELF , $month ;
  14. setlocale(LC_ALL,WPLANG); // set localization language
  15. // set the URI of your archives; this might not need to be changed (currently, it's http://yoursite.com/archives/)
  16. $now = gmdate('Y-m-d H:i:s'); // get the current GMT date
  17.  
  18. if (($format == 'both') || ($format == 'block')) { // check to see if we are supposed to display the block
  19.     $qy = mysql_query("SELECT distinct year(post_date) as year, post_status
  20.         FROM $tableposts 
  21.         WHERE post_status='publish'
  22.         AND post_date <= NOW()
  23.         ORDER BY year desc");
  24.     // loop to create the small archive block with year/month links
  25.     while($years = mysql_fetch_array($qy)) {
  26.     echo('<strong><a href="'.get_year_link($years[year]).'">'.$years[year].'</a>:</strong> ');
  27.         $qm = mysql_query("SELECT distinct month(post_date) as monthv
  28.             FROM $tableposts 
  29.             ORDER BY monthv  asc") or die(mysql_error());
  30.            
  31.             for ($i=1; $i<=12; $i++)
  32.             {
  33.                     $q = mysql_query("SELECT *, year(post_date) as year
  34.                     FROM $tableposts 
  35.                     WHERE year(post_date)='$years[year]'
  36.                     AND month(post_date)='$i'
  37.                     AND post_status='publish'
  38.                     AND post_date <= NOW()
  39.                     ORDER BY id desc") or die(mysql_error());
  40.                     $sm =    $month[zeroise($i,2)]; // get the shortened month name; strtotime() localizes
  41.  
  42.                     if(mysql_num_rows($q)) 
  43.                         { echo('<a href="'.get_month_link( $years[year], $i ).'">'.$sm.'</a> '); }
  44.                     else 
  45.                         { echo('<span class="emptymonth">'.$sm.'</span> '); }
  46.             }
  47.            
  48.             echo('<br />');
  49.     }
  50.     echo ('<br /><br />');
  51. }
  52.  
  53. if (($format == 'both') || ($format == 'list')) { //check to see if we are supposed to display the list
  54.     $qy = mysql_query("SELECT distinct year(post_date) as year, post_status
  55.         FROM $tableposts 
  56.         WHERE post_status='publish'
  57.         AND post_date <= NOW()
  58.         ORDER BY year desc");
  59.     // loop to display links to all posts, sorted by descending month and day
  60.     while($years = mysql_fetch_array($qy)) {
  61.         $qm = mysql_query("SELECT distinct month(post_date) as monthv FROM $tableposts ORDER BY monthv desc") or die(mysql_error());
  62.         while($date = mysql_fetch_array($qm)) {
  63.             $q = mysql_query("SELECT *, year(post_date) as year, month(post_date) as monthv
  64.                 FROM $tableposts WHERE year(post_date)='$years[year]'
  65.                 AND month(post_date)='$date[monthv]'
  66.                 AND post_status='publish'
  67.                 AND post_date <= NOW()
  68.                 ORDER BY id desc") or die(mysql_error());
  69.             if(mysql_num_rows($q)) {
  70.                 $lm = $month[zeroise($date[monthv],2)]; // get the full month name; strtotime() localizes
  71.                 echo('<h2><a href="'.get_month_link( $years[year], $date[monthv] ).'">'.$lm.' '.$years[year].'</a></h2>');
  72.                 echo('<ul>');
  73.                 $q = mysql_query("SELECT *, year(post_date) as year, month(post_date) as monthv
  74.                     FROM $tableposts WHERE year(post_date)='$years[year]'
  75.                     AND month(post_date)='$date[monthv]'
  76.                     AND post_status='publish'
  77.                     ORDER BY post_date desc") or die(mysql_error());
  78.                 while($post = mysql_fetch_array($q)) {
  79.                     if ($post[post_date_gmt] <= $now) {
  80.                         if ($catID != '') { // check to see if a category id was specified in the arguments
  81.                             // get the categories that are attached to the current post
  82.                             $cats = $wpdb->get_col("SELECT category_id FROM $wpdb->post2cat WHERE post_id = $post[ID]");
  83.                             $found=false;
  84.                             foreach ($cats as $cat) { // look to see if the specified category is attached to the current post
  85.                                  if ($cat == $catID) $found=true;
  86.                                }
  87.                                if (!$found) echo('<li><a href="'.get_permalink($post[ID]).'">'.$post[post_title].'</a></li>');
  88.                         }
  89.                         else echo('<li><a href="'.get_permalink($post[ID]).'">'.$post[post_title].'</a></li>');
  90.                     }
  91.                 }
  92.                 echo ('</ul><br />');
  93.             }
  94.         }
  95.     }
  96. }
  97. }
  98. ?>

Tags: ,

categories IT

GFW又升级了

现在通过Google搜索敏感关键词不会断网,但返回的内容是乱码。 想到最近blogspot又解封了,看来GFW的封锁政策正在进行大的调整。

Tags:

categories IT

Windows Live Writer 测试贴

微软发布了Windows Live Writer 1.0 beta, 一个blog的离线书写工具. 不只是支持Live Space, 还支持其他blog系统,比如我现在用的Wordpress.  感兴趣的朋友可以从 cnbeta 下载。 

Tags:

categories IT

数码相机的突发奇想之二

Avalon在数码相机的突发奇想 留言中提出一个很有趣的设想,就此和他在msn进一步聊了聊。感觉他提出的设想很妙,如果真能实现,就酷毙了!

聊天内容如下:

avalon 说:
呵呵,关于数码相机的突发奇想
我给你回了一个


Oldmonk( http://www.doyj.com ) 说:
哦?


avalon 说:
瞎说两句,


Oldmonk( http://www.doyj.com ) 说:
我是觉得将来很有可能对镜头的要求越来越简单,越来越小,越来越便宜,镜头的很多功能会转到处理器上


avalon 说:
但我觉得是这样,现在处理器能对数据作处理,但不会增加熵,高质量的镜头就是要采集更多的熵,这是个守恒的关系


Oldmonk( http://www.doyj.com ) 说:

Oldmonk( http://www.doyj.com ) 说:
看到你的评论了 , 很绝妙的想法!


avalon 说:
我希望能有个3d camera出来,就好比现在的d3d或ogl渲染一样


Oldmonk( http://www.doyj.com ) 说:
嗯,要是真有就酷了,有没有可能通过双镜头,或多镜头,估算出每个象素的景深
Oldmonk( http://www.doyj.com ) 说:
也不要
Oldmonk( http://www.doyj.com ) 说:
可能只要通过变焦镜头,把真个变焦过程走一遍
Oldmonk( http://www.doyj.com ) 说:
通过评估哪些像素在什么时候最清楚,最锐利,来估算出这个像素位置的距离


avalon 说:
也可能,如果能用计算机控制镜头的参数,应该也可能估算出真正的景深
avalon 说:
这样的好处就是,你可以随便制定背景的虚实了


Oldmonk( http://www.doyj.com ) 说:
嗯,我有个朋友他做自动质量检测,就是通过镜头的变焦来获取产品的高度数据
Oldmonk( http://www.doyj.com ) 说:
要不你给申请专利吧

avalon 说:
那样的话,所有的摄影技巧都不要了,只要在计算机上后期处理好了
avalon 说:
呵呵,这要早些光学书来看看,要推到些公式才行


Oldmonk( http://www.doyj.com ) 说:

Oldmonk( http://www.doyj.com ) 说:
我把我们这段谈话扔到blog上了

有点吓到了

http://www.google.com/searchhistory/ 查到了自己这几个月的搜索纪录,不但有搜索的关键词纪录,在搜索结果中看了哪些网站都一清二楚。

想起去年年底自己写的一个blog: http://www.doyj.com/archives/80

Tags: ,

categories IT

电信宽带与网通宽带

我家里是电信的Lan宽带,下载的峰值速度一般在128K字节美妙,大约1MBPS的带宽。 妹妹家是网通的Lan宽带,下载的峰值速度是256K字节每秒,大约2MBPS的带宽。

今天在家里给Blog家了一个XSPF播放器插件,选了9首歌放进去,这样大家可以边看blog边听音乐。在家里的电信宽带上试的都很好,每首歌都播放非常流畅。今晚去了趟妹妹家,发现用她的网通宽带只有第3,6,8首播放流畅,其他都断断续续,根本没法听。

难道这是因为电信和网通互联有问题?

Tags: ,

categories IT

RSS Reader

在一个程序员论坛做了一次有关RSS Reader的投票调查,投票的一共有13人。投票结果是,有三人使用离线RSS Reader, 一人使用在线的Reader, 其他9人不使用。有点让自己震惊。身边非技术圈的人没看到一个在用,没想到技术圈里使用的比率也是这么低。

自己原先一直用Firefox的一个RSS Reader插件,前几天转到了Google Reader上,这样到了外地网吧也能看了。我订的RSS不多, 请看http://www.doyj.com/%E6%88%91%E8%AE%A2%E7%9A%84rss/
从今天起,在我的blog里也搞“您使用的RSS Reader”调查,欢迎大家在左边投票区投票。

8月3日编辑:投票放了2两天没人投,撤下 :(

Tags: , , ,

categories IT

给历史我记录首页加上了最新文章的RSS Feed

原来在特殊页面的最新页面才能找到,这次给提到了首页菜单栏里,欢迎大家订阅

RSS: http://www.recordhistory.org/mediawiki/index.php?title=Special:Newpages&feed=rss

Tags: , ,

categories IT

Page 12 of 14« First...1011121314