Skip to content

Instantly share code, notes, and snippets.

View trydofor's full-sized avatar
🖖
may the force be with you

trydofor

🖖
may the force be with you
View GitHub Profile
@trydofor
trydofor / curl
Last active September 9, 2017 05:36
curl sample
# POST
curl --include
--request POST
--header "Content-type: application/json"
--data '{"name":"Nuthanger Farm","location":{"lat" : 51.244031,"long" : -1.263224}}'
http://localhost:9000/trydofor
# GET
curl --include http://localhost:9000/trydofor
@trydofor
trydofor / sublime-imfix.c
Created August 16, 2016 03:21
sublime使用fctix中文输入法,光标跟随,open folder+terminal正常
/*
sublime-imfix.c
Use LD_PRELOAD to interpose some function to fix sublime input method support for linux.
By Cjacker Huang <jianzhong.huang at i-soft.com.cn>
By whitequark@whitequark.org
How to compile:
gcc -shared -o libsublime-imfix.so sublime_imfix.c `pkg-config --libs --cflags gtk+-2.0` -fPIC
How to use:
LD_PRELOAD=./libsublime-imfix.so sublime_text
@trydofor
trydofor / mvn-mkdir
Last active September 9, 2017 05:35
maven mkdir
#!/bin/bash
pkg=`echo $1 | tr '.' '/'`
mkdir -p src/{main,test}/resources
mkdir -p src/{main,test}/java/$pkg
@trydofor
trydofor / dotXmodmap
Last active January 12, 2017 01:24
dotXmodmap
! xmodmap -pke|grep -E ' (Caps|Cont|Home|Next|[hjkl] )'
! xev
! 交换Caps(66)和Ctrl(37)
remove Lock = Caps_Lock
remove Control = Control_L
keysym Control_L = Caps_Lock
keysym Caps_Lock = Control_L
add Lock = Caps_Lock
add Control = Control_L
@trydofor
trydofor / emacs-client
Last active September 9, 2017 05:34
emacs-client
#!/bin/bash
if [[ -z $(ps -C 'emacs --daemon' -o pid=) ]]; then
env LC_CTYPE=zh_CN.UTF-8 emacs --daemon
fi
/usr/bin/emacsclient "$@"
@trydofor
trydofor / dotxmodmaprc
Last active May 2, 2017 13:29
支持shift选择的映射
!! Exec=bash -c "/usr/bin/xmodmap $HOME/.xmodmaprc"
! xmodmap .xmodmaprc
! xmodmap -pke|grep -E ' (Caps|Cont|Home|Next|Up|Down|Left|Right|Home|End|Prior|Next|Delete|Escape|Mode_switch)'
! xev
!! Control_L(37)变成Mode_switch
remove Control = Control_L
keycode 37 = Mode_switch NoSymbol
!! Caps_Lock(66)变成Control_L
@trydofor
trydofor / window-shortcut.org
Last active May 7, 2017 03:16
window-shortcut

Win 快捷键归类

C = Control Btn1 = 左键 M = Alt Btn2 = 中键 S = Shift Btn3 = 右键 W = Window Wheel = 滚轮 左手: 1234 qwer asdf zxcv 右手 :yuiop hjkl; nm,./ 方向: aswd hjkl

Win + Ctl 全局功能/窗口移动

@trydofor
trydofor / ssh-auto-login.txt
Created September 15, 2017 01:25
ssh auto login
#!/bin/bash
cat << EOF
#On Client:
[ -d ~/.ssh ] || mkdir .ssh
[ -f ~/.ssh/id_rsa.pub ] || ssh-keygen -t rsa
cat ~/.ssh/id_rsa.pub
# On Server
[ -d ~/.ssh ] || mkdir .ssh
cat >>~/.ssh/authorized_keys <<END
@trydofor
trydofor / date-calc.java
Created September 15, 2017 01:25
日期计算
public static void main(String[] args) throws ParseException {
SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
c.set(2017,10,30); // 月份从0开始,10标识11月
System.out.println(s.format(c.getTime()));
c.add(Calendar.MONTH,3); // 月末对齐
System.out.println(s.format(c.getTime()));
Date d = s.parse("2017-13-45"); // 会有解析错误么?不会