Skip to content

Instantly share code, notes, and snippets.

View wangchen's full-sized avatar
🐣
On vacation

wangchen wangchen

🐣
On vacation
  • China
View GitHub Profile
@wangchen
wangchen / realpath
Last active December 25, 2015 02:08
Realpath in OS X implemented by python
alias realpath='python -c '\''import os,sys; print (os.path.abspath(sys.argv[1]) if len(sys.argv)>1 and os.path.exists(sys.argv[1]) else "Invalid path\nUsage: realpath <path>")'\'
@wangchen
wangchen / apkinfo
Last active December 27, 2015 15:49
Simple apk information
#!/usr/bin/env sh
function apkinfo()
{
for part in $(aapt d badging $1 |grep package)
do
echo $part
done
echo "size: $(wc -c $1 |cut -d " " -f2)"
echo "hash: $(shasum $1 |cut -d " " -f1)"
@wangchen
wangchen / dbsize.sql
Last active January 3, 2016 02:29
Show size of all databases
SELECT table_schema AS "Database name", SUM(data_length + index_length) / 1024 / 1024 AS "Size (MB)" FROM information_schema.TABLES GROUP BY table_schema;
#!/bin/bash
# CentOS rbenv system wide installation script
# Forked from https://gist.github.com/1237417
# Installs rbenv system wide on CentOS 5/6, also allows single user installs.
# Install pre-requirements
yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel \
make bzip2 autoconf automake libtool bison iconv-devel git-core
@wangchen
wangchen / Preferences.sublime-settings
Created January 26, 2014 06:04
SublimeText Settings
{
"always_prompt_for_file_reload": false,
"always_show_minimap_viewport": false,
"animation_enabled": true,
"atomic_save": true,
"auto_close_tags": true,
"auto_complete": true,
"auto_complete_commit_on_tab": false,
"auto_complete_delay": 50,
"auto_complete_selector": "source - comment, meta.tag - punctuation.definition.tag.begin",
@wangchen
wangchen / Default (OSX).sublime-keymap
Created January 26, 2014 06:05
SublimeText Keymap
[
{ "keys": ["ctrl+l"], "command": "expand_selection", "args": {"to": "line"} },
{ "keys": ["ctrl+d"], "command": "find_under_expand" },
{ "keys": ["ctrl+w"], "command": "expand_selection", "args": {"to": "scope"} },
{ "keys": ["ctrl+i"], "command": "expand_selection", "args": {"to": "indentation"} },
{ "keys": ["ctrl+]"], "command": "goto_definition" },
{ "keys": ["super+l"], "command": "show_overlay", "args": {"overlay": "goto", "text": ":"} },
{ "keys": ["ctrl+["], "command": "reveal_in_side_bar" }
]
@wangchen
wangchen / .zshrc
Created January 26, 2014 06:20
ZSH Configuration
ZSH=$HOME/.oh-my-zsh
ZSH_THEME="robbyrussell"
DISABLE_CORRECTION="true"
plugins=(git osx brew rake rbenv tmux)
source $ZSH/oh-my-zsh.sh
# vi-mode
bindkey -v
bindkey -a u undo
bindkey -a '^R' redo
@wangchen
wangchen / timer_server.php
Created April 22, 2014 05:33
A simple swoole timer helper
<?php
error_reporting(E_ALL ^ E_NOTICE);
/**
* Timer Manager
*/
class TimerManager
{
private $_timers;
private $_timeouts;
@wangchen
wangchen / swoole_segmentation_fault.coredump
Created April 24, 2014 10:33
swoole segmentation fault
*** glibc detected *** php: free(): invalid pointer: 0x00000000019be940 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x7eb96)[0x7fc6664a5b96]
php(sapi_shutdown+0x17)[0x686b77]
php(main+0x3d1)[0x464bf1]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed)[0x7fc66644876d]
php[0x464ddd]
======= Memory map: ========
00400000-00b8d000 r-xp 00000000 ca:01 1192719 /usr/bin/php5
00d8d000-00e2f000 r--p 0078d000 ca:01 1192719 /usr/bin/php5
@wangchen
wangchen / demo.php
Created April 25, 2014 14:25
refectory
<?php
$mem = null;
$my = null;
/**
* Create tables
* @param array $tbl_num_list example: [100, 100, 100]
*/
function create_tables ($tbl_num_list) {