Skip to content

Instantly share code, notes, and snippets.

@hqingyi
hqingyi / mkfileswap.sh
Created July 6, 2015 09:25
make file swap.
#!/bin/bash
# N and BYTES may be followed by the following multiplicative suffixes:
# c =1, w =2, b =512, kB =1000, K =1024, MB =1000*1000, M =1024*1024
help(){
echo "useage: `basename $0` -o full_path -b block_size(default 1K) -c block_count(default 2M)"
}
while getopts 'o:b:c:' OPT; do
case $OPT in
@hqingyi
hqingyi / git_ssh.md
Last active October 23, 2015 08:05
使用ssh搭建简易私有的git服务器

准备

相关服务

apt-get install git

用户配置

adduser --shell /usr/bin/git-shell git
@hqingyi
hqingyi / bind_key_for_popclip.md
Created November 5, 2015 07:20
用键盘调出 PopClip

通常情况下,我们调出 PopClip 工具条需要用鼠标选中一段文字,但这在编辑文字时会显得有些不便,那么如何直接用键盘调出 PopClip 呢?Mac 自带的小机器人 Automator,可以实现很多 Mac 自动化的流程。打开 Automator,新建一个「Service」(即「服务」),利用 AppleScript 写一段代码。这里要注意的是,上方的「服务」我们要选择「没有输出」。

复制下面代码替换:

on run {input, parameters}

  tell application "PopClip" to appear
 
@hqingyi
hqingyi / tmux-cheatsheet.markdown
Created November 13, 2015 04:16 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@hqingyi
hqingyi / shadowsocks
Created November 15, 2015 12:13
Shadowsocks init.d
#!/bin/sh
start(){
ssserver -c /etc/shadowsocks.json -d start
}
stop(){
ssserver -c /etc/shadowsocks.json -d stop
}
case "$1" in
start)
@hqingyi
hqingyi / yourservice.conf
Created November 23, 2015 07:05 — forked from c4milo/yourservice.conf
upstart example script
# Ubuntu upstart file at /etc/init/yourservice.conf
pre-start script
mkdir -p /var/log/yourcompany/
end script
respawn
respawn limit 15 5
start on runlevel [2345]
@hqingyi
hqingyi / python_infrastructure.md
Created December 3, 2015 12:40 — forked from onlytiancai/python_infrastructure.md
python 基础设施讨论贴

python项目通用组件和基础服务

很多公司都大量使用了python,其中有一些开发规范,code guidline, 通用组件,基础框架是可以共用的。

每个公司都自己搞一套, 太浪费人力,我想开一帖和大家讨论一下这些python基础设施的搭建。

原则是我们尽量不重新发明轮子,但开源组件这么多,也要有个挑选的过程和组合使用的过程,在这里讨论一下。

另一方面,有些开源组件虽然强大,但我们不能完全的驾驭它,或只使用其中很少的一部分,我们就可以考虑用python实现一个简单的轮子,可控性更强,最好不要超过300行代码。

@hqingyi
hqingyi / ngrok-selfhosting-setup.md
Created December 9, 2015 01:22 — forked from lyoshenka/ngrok-selfhosting-setup.md
How to setup Ngrok with a self-signed SSL cert

Intro

The plan is to create a pair of executables (ngrok and ngrokd) that are connected with a self-signed SSL cert. Since the client and server executables are paired, you won't be able to use any other ngrok to connect to this ngrokd, and vice versa.

DNS

Add two DNS records: one for the base domain and one for the wildcard domain. For example, if your base domain is domain.com, you'll need a record for that and for *.domain.com.

Different Operating Systems

@hqingyi
hqingyi / bc3_git_config.md
Last active December 9, 2015 06:59
BeyondCompare as git mergetool/difftool

Use Beyond Compare as git mergetool/difftool

准备BeyondCompare

打开BeyondCompare安装好Command Line Utils

  • /usr/local/bin/bcomp
  • /usr/local/bin/bcompare

Git版本>2.3,直接配置bc3即可

git config --global diff.tool bc3
@hqingyi
hqingyi / sync_forked_repo.md
Created December 9, 2015 14:24
How to sync a github forked repository

How to sync a github forked repository

In your local clone of your forked repository, you can add the original GitHub repository as a "remote". ("Remotes" are like nicknames for the URLs of repositories - origin is one, for example.) Then you can fetch all the branches from that upstream repository, and rebase your work to continue working on the upstream version.

Sample