Skip to content

Instantly share code, notes, and snippets.

@patricksuo
patricksuo / lua_proxy_demo.lua
Created October 6, 2016 13:27
lua proxy demo
proxy = {}
proxy.wrap = function(t)
return proxy.wraphelper(t, nil, nil)
end
proxy.wraphelper = function(t, pm, path2me)
-- print("wraphelper", t, pm, path2me)
local m = {}
m.__path = path2me
@patricksuo
patricksuo / is_little_endian.c
Created October 5, 2016 12:32
c code snippet: is_little_endian
int is_little_endian() {
int a = 1;
return ((char *)(&a))[0]== 1;
}
@patricksuo
patricksuo / vscode
Created October 5, 2016 06:42
my visual studio code config
// Place your settings in this file to overwrite the default settings
{
"files.exclude": {
"*.swap": true,
"*.o": true
}
}
# 由于公司VPN就是一坨💩
# http://superuser.com/questions/458730/keep-ssh-port-forwarding-connection-alive
while true; do
{ while true; do echo echo ping; sleep 10; done } | \
ssh -R 5555:localhost:22 user@remotehost -o ExitOnForwardFailure=yes -v
sleep 10
done
#!/usr/bin/env bash
# via http://osxdaily.com/2014/10/25/fix-wi-fi-problems-os-x-yosemite/
launchctl unload -w /System/Library/LaunchDaemons/com.apple.wifid.plist
launchctl load -w /System/Library/LaunchDaemons/com.apple.wifid.plist
@patricksuo
patricksuo / part of .zshrc
Last active October 3, 2017 16:46
part of .zshrc
alias tlist="tmux list-session"
alias tnew="tmux new -s"
alias tattach="tmux attach -t"
alias siftx="sift -n -A3 -B3 --binary-skip --exclude-ext out"
alias siftn="sift -n --binary-skip --exclude-ext out, --exclude-dirs .svn"
alias svnst="svn st|grep -v \"?\""
export TERM="xterm-256color"
# https://github.com/zeit/hyper/issues/1613#issuecomment-311172029
@patricksuo
patricksuo / .tmux.conf
Created April 19, 2016 03:03
tmux conf
#此类配置可以在命令行模式中输入show-options -g查询
set-option -g base-index 1 #窗口的初始序号;默认为0,这里设置为1
set-option -g display-time 5000 #提示信息的持续时间;设置足够的时间以避免看不清提示,单位为毫秒
set-option -g repeat-time 1000 #控制台激活后的持续时间;设置合适的时间以避免每次操作都要先激活控制台,单位为毫秒
set-option -g status-keys vi #操作状态栏时的默认键盘布局;可以设置为vi或emacs
set-option -g status-right "#(date +%H:%M' ')" #状态栏右方的内容;这里的设置将得到类似23:59的显示
set-option -g status-right-length 10 #状态栏右方的内容长度;建议把更多的空间留给状态栏左方(用于列出当前窗口)
set-option -g status-utf8 on #开启状态栏的UTF-8支持
set -g default-terminal "xterm-256color" # VIM 配色
@patricksuo
patricksuo / goscope
Created April 8, 2016 06:24
cscope helper script for golang
#!/bin/sh
find $PWD -name '*.go' -exec echo \"{}\" \; | sort -u > cscope.files
#cscope -bvq
cscope -b
@patricksuo
patricksuo / vim config
Last active October 3, 2017 16:45
vim config
# 1. install plugin manager vundle
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
# 2. save vimrc
curl https://gist.github.com/sillyousu/c0fada443c00869f436e5daf7a0f4765/raw/8c5ed19be89a786873759ac1c78d56d0ebd99489/vimrc > $HOME/.vimrc
# 3. install other plugin
vim +PluginInstall +qall
# 4. install vim-go dependency
@patricksuo
patricksuo / gist:f9e11d4b1e0d5c7db1cf
Last active December 21, 2015 12:34
set and get a thread's CPU affinity mask lab
#define _GNU_SOURCE
#include <sched.h>
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h> /* abort() */
#include <stdarg.h>
#include <string.h>
#include <errno.h>