Skip to content

Instantly share code, notes, and snippets.

@isayme
isayme / id_chk.py
Created February 5, 2014 03:45
id check python script,
#!/usr/bin/python
# -*- coding: utf-8 -*-
import re;
# id check function
def IC_chk(ic_serial):
# value array
iW = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2, 1];
# characters in ID
@isayme
isayme / inotify.c
Last active August 29, 2015 13:57
donot touch my files if you are not root!
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/select.h>
// 典型自执行函数格式:
// (funtion(root, factory) {
// // do stuff here
// })(this, factoryFunc);
// 其中`root`就是`this`, `factory`就是`factoryFunc`;
// 而`this`又根据环境的不同而不同, 具体见下面的注释.
(function(root, factory) {
// Set up Backbone appropriately for the environment. Start with AMD.
// 如果是AMD的模块规范(require.js使用的规范, 主要用于浏览器端).
body {
background: url(/img/bg.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
$black: #333333;
$white: #f6f6f6;
$gray: #aaaaaa;
$silver: #dddddd;
$red: #e54d42;
$green: #1abc9c;
$yellow: #FFDC00;
$blue: #3498db;
$navy: #34495e;
*, *:before, *.after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
margin: 0;
padding: 0;
}
.bg-black { background-color: #333333; }
.bg-white { background-color: #f6f6f6; }
@isayme
isayme / nogoogleredirect.user.js
Created August 13, 2014 07:56
油猴脚本 => 禁止点击Google搜索结果的跳转.
// ==UserScript==
// @name noGoogleRedirect
// @namespace http://www.onefloweroneworld.com
// @description 禁止点击Google搜索结果的跳转.
// @include http://www.google.com/search?*
// @include https://www.google.com/search?*
// @version 0.1
// @author iSayme <isaymeorg@gmail.com>
// @run-at document-end
// @grant none
@isayme
isayme / linux_affinity.c
Created December 6, 2012 05:52
利用linux线程亲和性绑定,使所有的core(指逻辑核而不是物理核)满负荷运行
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <sched.h>
#include <pthread.h>
void test_proc(void *arg)
@isayme
isayme / cappkt.c
Created December 21, 2012 02:49
use libpcap to capture pkts in linux. Add filter 'tcp or udp'. gcc -g -o cappkt cappkt.c -lpcap
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <netinet/in.h>
#include <pcap/pcap.h>
// thread unsafe
void packet_handler(u_char *param, const struct pcap_pkthdr *header, const u_char *pkt_data)
{
struct tm *ltime;
@isayme
isayme / bash
Last active December 10, 2015 22:28
Linux setting
export PS1='\[\e[36;1m\]\u\[\e[01;30m\]@\[\e[32;1m\]\h:\[\e[01;35m\]\w \$ \[\e[0m\]'
export LESS_TERMCAP_mb=$'\E[01;31m'
export LESS_TERMCAP_md=$'\E[01;31m'
export LESS_TERMCAP_me=$'\E[0m'
export LESS_TERMCAP_se=$'\E[0m'
export LESS_TERMCAP_so=$'\E[01;44;33m'
export LESS_TERMCAP_ue=$'\E[0m'
export LESS_TERMCAP_us=$'\E[01;32m'