落絮飞雁

顺流而下,把梦做完

古韵西安——行走在美食与历史之间


顺利回家:-)开始整理游记,预计一天写一篇~ READ MORE →

数字雨特效——HTML版

没什么好说的,很简单的代码。效果可以在这里





Matrix——By LXFY











修改WP文章摘要长度

刚刚修改了一下WP的版式。改过之后正文框大了好多。但在首页上就显得空荡荡的。因为文章摘要默认只显示55个字符。偌大一个页面是只显示半句话着实不好看。
在模板中修改文章摘要的方法很简单,依旧是在function.php中添加函数实现。但这次用的是WP默认生成摘要的方法the_excerpt()修改的~
在wp-includes/formatting.php中可以找到wp_trim_excerpt方法,可以看到这里的默认值是55,修改为合适值即可。而且不必担心WP会截取到半个汉字什么的。

$excerpt_length = apply_filters( 'excerpt_length', 220 );

Enjoy~

替换Gavatar为V2EX CDN

由于众所周知的原因,Gavatar会拖慢网站的访问速度。可以试着用一些CDN服务来为Gavatar提速。
比如替换为V2EX的CDN

/*use-V2EX-CDN-Gavatar*/
function getV2exAvatar($avatar) {
        $avatar = str_replace(array("www.gravatar.com/avatar","0.gravatar.com/avatar","1.gravatar.com/avatar","2.gravatar.com/avatar"),"cdn.v2ex.com/gravatar",$avatar);
        return $avatar;
}
add_filter('get_avatar', 'getV2exAvatar');

评论回复后邮件通知——无插件实现

还是利用函数function.php文件实现。

添加:

//comment_mail_notify
function comment_mail_notify($comment_id) {
  $comment = get_comment($comment_id);
  $parent_id = $comment->comment_parent ? $comment->comment_parent : '';
  $spam_confirmed = $comment->comment_approved;
  if (($parent_id != '') && ($spam_confirmed != 'spam')) {
    $wp_email = 'no-reply@' . preg_replace('#^www.#', '', strtolower($_SERVER['SERVER_NAME']));//发件人e-mail地址
    $to = trim(get_comment($parent_id)->comment_author_email);
    $subject = '您在['.get_option("blogname").']的留言有了回复';
    $message = '

 

‘.trim(get_comment($parent_id)->comment_author).’, 您好!

 

这是您在《’.get_the_title($comment->comment_post_ID).’》中的留言:
‘ .trim(get_comment($parent_id)->comment_content).’

 

以下是’.trim($comment->comment_author).’ 给您的回复:
‘ .trim($comment->comment_content).’

 

您可以点击这里查看回复的完整内容.

 

‘ . get_option(‘blogname’) . ‘内容已经更新,欢迎再度光临!

 

此邮件为系统发出,请勿回复此邮件!

 

任何疑问,欢迎邮件admin@luoxufeiyan.com

 

‘; $from = “From: “” . get_option(‘blogname’) . “” <$wp_email>”; $headers = “$fromnContent-Type: text/html; charset=” . get_option(‘blog_charset’) . “n”; wp_mail( $to, $subject, $message, $headers ); //echo ‘mail to ‘, $to, ‘
‘ , $subject, $message; // for testing } } add_action(‘comment_post’, ‘comment_mail_notify’); //comment_mail_notify end

即可。
参考自:wordpress 3.8 不使用插件,实现email通知访客其评论有人回复——老牛博客

鄙视一下『多说评论』

一直用的是Wordpress自带的评论框,评论回复后不会邮件提醒层主。所以想图个方便直接装个『多说』,结果刚装上,就开始爬网站的所有文章和用户。不仅如此,甚至连禁止评论的文章和私密文章都被多说一五一十的复制到了自家的服务器上。这样的插件,真心不敢用啊……

还是自己摸索着加一个邮件回复功能吧。

在页脚添加时间和内存消耗等信息

在HDOJ底部,会显示出此次访问的请求次数和时间等信息。依样在本站上也添加了一个。还是通过在function中添加函数实现。

在function.php中添加:

function performance( $visible = false ) {

    $stat = sprintf(  'Total %.3f seconds query %d using %.2fMB memory',
        timer_stop( 0, 3 ),
        get_num_queries(),
        memory_get_peak_usage() / 1024 / 1024
        );

    echo $visible ? $stat : "" ;
}
// Show performance detail End

之后在需要调用的地方插入


即可~

 

效果如图

代码高亮插件WP-Code-Highlight 样式美化

Update150628:
修复了行号异常的BUG,代码已经更新。详细请见这里

样式代码:

.prettyprint,
pre.prettyprint {
    background-color: #000;
    font-family:Source Code Pro,inherit;
    border: none;
    overflow: hidden;
    padding: 10px 15px;
}
.preprint.ol.linenums li{line-height:16px;margin:0px;padding:5px;list-style:none;}
.preprint.ol.linenums li:before,ol.linenums li:after{content:none;}
.preprint.ol.linenums li{margin:0;padding-left:27px;color:#ff0000;}
.preprint.ol.linenums li.L0,ol.linenums li.L0,ol.linenums li.L1,ol.linenums li.L2,ol.linenums li.L3,ol.linenums li.L4,ol.linenums li.L5,ol.linenums li.L6,ol.linenums li.L7,ol.linenums li.L8,ol.linenums li.L9{
	list-style-type:decimal;
	color:#FF0000;
}
.preprint.ol.linenums li.L0,ol.linenums li.L1,ol.linenums li.L3,ol.linenums li.L5,ol.linenums li.L7,ol.linenums li.L9{
	list-style-type:decimal;
        background-color: #191919;
}
.prettyprint .com { color: #93a1a1; }
.prettyprint .lit { color: #AE81FF; }
.prettyprint .pun,
.prettyprint .opn,
.prettyprint .clo { color: #F8F8F2; }
.prettyprint .fun { color: #dc322f; }
.prettyprint .str,
.prettyprint .atv { color: #E6DB74; }
.prettyprint .kwd,
.prettyprint .tag { color: #F92659; }
.prettyprint .typ,
.prettyprint .atn,
.prettyprint .dec,
.prettyprint .var { color: #A6E22E; }
.prettyprint .pln { color: #66D9EF; }

这个CSS样式是在乐趣公园看到的。稍微改动了一下,显示行号为白色,同时支持Source Code Pro字体。

本文转载自:乐趣公园。版权属原作者。原文链接:http://googlo.me/2882.html

Source Code Pro——一套适合代码显示的开源字体

实在是不能忍受VS的默认字体的显示效果了,看不清楚不说,甚至连1和l都分不清楚,相比Linux和OSX下默认的字体差太多了。于是就在网上找到了这套Adobe开发的开源字体,叫『Source Code Pro』,项目页面在这里。不仅是等宽字,还支持ClearType,在MacType下渲染效果也不错。抽空把网站上代码的字体也改了:-)

字体下载:Github

显示效果:

POJ3785:The Next Permutation——全排列问题

Description

For this problem, you will write a program that takes a (possibly long) string of decimal digits, and outputs the permutation of those decimal digits that has the next larger value (as a decimal number) than the input number. For example:

123 -> 132
279134399742 -> 279134423799

It is possible that no permutation of the input digits has a larger value. For example, 987.
Input

The first line of input contains a single integer P, (1 ≤ P ≤ 1000), which is the number of data sets that follow. Each data set is a single line that contains the data set number, followed by a space, followed by up to 80 decimal digits which is the input value.
Output

For each data set there is one line of output. If there is no larger permutation of the input digits, the output should be the data set number followed by a single space, followed by the string BIGGEST. If there is a solution, the output should be the data set number, a single space and the next larger permutation of the input digits.
Sample Input

3
1 123
2 279134399742
3 987
Sample Output

1 132
2 279134423799
3 BIGGEST


在STL下瞬间变水题……

输入数组时用scanf()而不用gets()。原因是scanf()遇到空格时认为输入结束,而gets()会输入空格:样例显然是以空格而非 结束标志来判断的。所以,乖乖scanf()吧。

还有就是注意格式,这题又PE了,郁闷……看了看是IDE坏掉了。

放上代码:

#include
#include
#include
char num[1010];
using namespace std;
int main()
{
	int p, n, cache;
	scanf("%d", &p);
	while (p--)
	{
		memset(num, 0, sizeof(num));
		cache = n = 0;
		scanf("%d", &cache);
		scanf("%s", num);
		printf("%d ", cache);
		if (next_permutation(num, num + strlen(num)))
			puts(num);
		else printf("BIGGESTn");
	}
	return 0;
}