Skip to content

Instantly share code, notes, and snippets.

View huwan's full-sized avatar

Hu Wan huwan

  • City University of Hong Kong
  • 00:22 (UTC +08:00)
View GitHub Profile
@huwan
huwan / grey-style
Created April 20, 2013 16:06
将网站变成黑白(灰)色代码。把代码放到页面的<head></head>中间,或者去掉style标签后放到css文件中去。
<style>
#J-slide, .header,.main,.nav a ,.slide-number, #J-slide, .slide .bg{ filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1); zoom: 1;}
.follow_btn .icon {color:#ccc;}
html {
-webkit-filter: grayscale(100%);
-moz-filter: grayscale(100%);
-ms-filter: grayscale(100%);
-o-filter: grayscale(100%);
@huwan
huwan / artii.sh
Created March 4, 2014 10:06
遍历artii 支持的font,并将artii 处理后的文本内容输出到文件
#! /bin/bash
cat artiifont.txt | while read line
do
echo "${line}:" >> cf.txt
artii 'Cache' -f ${line} >> cf.txt
done
@huwan
huwan / cmath.c
Last active August 29, 2015 14:01
cmath
/*!
* @brief Checks if n is a power of 2.
* @returns true if n is power of 2
*/
static inline bool IsPower2(UINT32 n)
{
return ((n & (n - 1)) == 0);
}
/*!
@huwan
huwan / README.md
Last active August 29, 2015 14:02
Linux 定时使用脚本检测程序运行状态并通过飞信进行通知

Linux 定时使用脚本检测程序运行状态并通过飞信进行通知

  • 可以通过输入进程号(精确匹配)(注)或者特定的进程名称(模糊匹配)
  • 当程序完成退出后,通过中国移动[命令行飞信] 1 进行提醒
  • 需结合crontab 计划任务服务,每隔10分钟执行一次检测任务

注:因为是使用ps -ef + grep 所以,有可能一个进程号在多列出现,并不是完全意义上的精确匹配,但实际使用中一般不会出问题,可以先人工确认一下是否唯一

@huwan
huwan / ustc-logo-gif.html
Created June 12, 2014 06:44
中国科学技术大学校徽加动画效果
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!-- saved from url=(0023)http://sts.ustc.edu.cn/ -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>中国科学技术大学科技哲学教研部</title>
<meta name="GENERATOR" content="MSHTML 8.00.6001.19170"></head>
<body>
<table border="0" cellspacing="0" cellpadding="0" width="894" bgcolor="#ffffff" align="center">
<tbody>
<tr>
<td height="140" background="http://sts.ustc.edu.cn/images/top.jpg">
@huwan
huwan / totomo.sh
Created June 22, 2014 10:37
打印日历笔记本的今明两天(2014年)
#! /bin/bash
#yesterday=`date -d '-1 day' +%Y%m%d`
today=`date +%Y%m%d`
pagebegin=`date -f <(seq 20140101 $today) +%F 2>/dev/null |wc -l`
pageend=$(($pagebegin+1))
filename="daydayup.pdf"
username="printer"
if [ ! -f hist.ory ]; then
@huwan
huwan / reboot.sh
Created June 22, 2014 10:49
ubuntu 系统在开机启动后再自动重启一次
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
@huwan
huwan / setjmp
Created July 6, 2015 01:59
setjmp和longjmp函数使用
// http://blog.csdn.net/chenyiming_1990/article/details/8683413
#include <stdio.h>
#include <setjmp.h>
static jmp_buf buf;
void second(void) {
printf("second\n"); // 打印
longjmp(buf,1); // 跳回setjmp的调用处 - 使得setjmp返回值为1
}
@huwan
huwan / Buffer-layer tracing support for ext4-jbd2.patch
Last active September 30, 2015 03:38
[PATCH] Buffer-layer tracing support for jbd/jbd2 related repo: https://github.com/huwan/linux-buffer-debug
From 279cb88d74c75e5dc4876a2dcd1f1aefc62d60ba Mon Sep 17 00:00:00 2001
From: Wan Hu <wanhu@cnu.edu.cn>
Date: Thu, 3 Sep 2015 20:41:09 +0800
Subject: [PATCH] Buffer-layer tracing support for ext4/jbd2
---
fs/Kconfig | 4 +
fs/Makefile | 1 +
fs/jbd2-kernel.c | 254 +++++++++++++++++++++++++++++++++++++++++++
include/linux/buffer-trace.h | 52 +++++++++
@huwan
huwan / rc.local
Last active November 2, 2016 03:40
Create welcome message with access information.
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.