Skip to content

Instantly share code, notes, and snippets.

View git-snippets.sh
Squash commits on branch into one commit:
git log --oneline
git rebase -i HEAD~<number of commits back to include + 1>
# leave extra commit as "pick"
# leave oldest commit for this branch as "pick"
# change all others to s
# save and exit
# edit commit message
git push —force
View keybase.md

Keybase proof

I hereby claim:

  • I am shunfan on github.
  • I am shunfan (https://keybase.io/shunfan) on keybase.
  • I have a public key ASBUsJ6Y1krygFbwur1FW86m2zrFyf6ZlowF6GT9hMIx0wo

To claim this, I am signing this object:

@shunfan
shunfan / nginx_overrides
Created Nov 7, 2017 — forked from sheharyarn/nginx.overrides
Restart / Reload Nginx without Entering Sudo Password
View nginx_overrides
# Enter this command to create a sudoers override/include file:
# sudo visudo -f /etc/sudoers.d/nginx_overrides
# (Make sure you actually have this in your /etc/sudoers - Run `sudo visudo` to check)
# #includedir /etc/sudoers.d
# This file assumes your deployment user is `deploy`
# Nginx Commands
Cmnd_Alias NGINX_RESTART = /usr/sbin/service nginx restart
@shunfan
shunfan / reg.rb
Last active Jan 24, 2017
RHIT Class Registration
View reg.rb
#!/usr/bin/ruby
# INSTALL: gem install faraday
require 'faraday'
Faraday::Utils.default_params_encoder = Faraday::FlatParamsEncoder
username = ''
password = ''
term = ''
View word_count.rb
def word_count(content)
result = Hash.new(0)
content.downcase.scan(/\w+/) { |word| result[word] += 1 }
result
end
View take_natural_numbers.rb
# http://v2ex.com/t/74002
list = [0, 0, 0,
2295, 2295, 1530,
0, 0, 0, 0, 0,
1020, 1530, 1530, 1530, 1530, 2295, 2550, 1785,
0, 0, 0, 0, 0,
1020, 1530, 1530, 1530, 1530, 2295, 2550,
0, 0, 0, 0, 0,
1275, 1530, 1530, 1530, 1530, 1530,
0, 0, 0, 0, 0, 0]
@shunfan
shunfan / slugify.py
Last active Jun 25, 2017
Slugify Chinese
View slugify.py
# coding=utf-8
"""
Slugify for Chinese
没有优化多音字
优化多音字的项目有:
https://github.com/jiedan/chinese_pinyin
"""
import re
import unidecode