Skip to content

Instantly share code, notes, and snippets.

View mitnk's full-sized avatar
🦋
Wandering

Hugo Wang mitnk

🦋
Wandering
View GitHub Profile
@mitnk
mitnk / install_grep.sh
Created May 12, 2014 08:05
Install lastest GNU grep
mkdir -p tmp_dir_to_install_grep
cd tmp_dir_to_install_grep
wget https://ftp.gnu.org/gnu/grep/grep-2.18.tar.xz
tar xf grep-2.18.tar.xz
cd grep-2.18/
./configure && make && sudo make install
@mitnk
mitnk / tailf_least_postgresql_log.sh
Last active August 29, 2015 14:03
Tailf lastest PostgreSQL Log
path=`ps ax | grep -i 'postmaster' | grep -o '\-D\(/Library/Post.*\)' | awk -F D '{print $NF}'`
log_dir="${path}/pg_log"
log_name=`sudo ls -1t ${log_dir} | head -n1`
log_file="${log_dir}/${log_name}"
echo ""
echo "=========== $log_file =========="
echo ""
sudo tail -f "$log_file"
@mitnk
mitnk / simplify_dict_cn_scb.js
Created August 12, 2014 08:41
Simplify dict cn 的生词本
// ==UserScript==
// @name Simplify Dict.cn
// @namespace http://mitnk.com
// @version 0.1
// @description Simplify dict cn 的生词本
// @match http://scb.dict.cn/card.php*
// @copyright 2014+, mitnk
// for tampermonkey on Chrome.
// ==/UserScript==
@mitnk
mitnk / dbg.h
Last active August 29, 2015 14:17
A C logger header
// via: http://c.learncodethehardway.org/book/ex20.html
#ifndef __dbg_h__
#define __dbg_h__
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <time.h>
#!/usr/bin/env python
#
# Converts any integer into a base [BASE] number. I have chosen 62
# as it is meant to represent the integers using all the alphanumeric
# characters, [no special characters] = {0..9}, {A..Z}, {a..z}
#
# I plan on using this to shorten the representation of possibly long ids,
# a la url shortenters
#
@mitnk
mitnk / default.custom.yaml
Created August 20, 2012 05:52 — forked from lotem/default.custom.yaml
在Rime輸入方案選單中添加五筆、雙拼、粵拼、注音,保留你需要的
# default.custom.yaml
# save it to:
# ~/.config/ibus/rime (linux)
# ~/Library/Rime (macos)
# %APPDATA%\Rime (windows)
patch:
schema_list:
- schema: luna_pinyin # 朙月拼音
- schema: terra_pinyin # 地球拼音 dì qiú pīn yīn
@mitnk
mitnk / redis.conf
Created September 20, 2012 06:58
Redis config
# https://github.com/antirez/redis/blob/unstable/redis.conf
# Redis configuration file example
# Note on units: when memory size is needed, it is possible to specify
# it in the usual form of 1k 5GB 4M and so forth:
#
# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
@mitnk
mitnk / shuffle_array.c
Created November 20, 2012 06:39
Shuffle Array Algorithm
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define SIZE 10
void ShuffleArray_Fisher_Yates(char* arr, const int len)
{
int i = len, j;
char temp;
@mitnk
mitnk / linked_list.c
Created November 21, 2012 12:49
A simple linked list
#include <stdio.h>
#include <stdlib.h>
typedef struct Node {
int data;
struct Node *next;
} Node;
Node *create_node(int n)
{
@mitnk
mitnk / image_smaller.py
Last active December 10, 2015 01:28
Small Images with PIL
from PIL import Image
import os
import subprocess
import sys
def smaller_images():
if len(sys.argv) != 3:
print "Usage: python image_smaller.py <Path> 0.X"
return
path = sys.argv[1]