Skip to content

Instantly share code, notes, and snippets.

# 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 / word_count.rb
Created December 1, 2013 05:30
Word Count
def word_count(content)
result = Hash.new(0)
content.downcase.scan(/\w+/) { |word| result[word] += 1 }
result
end
@shunfan
shunfan / reg.rb
Last active January 24, 2017 03:18
RHIT Class Registration
#!/usr/bin/ruby
# INSTALL: gem install faraday
require 'faraday'
Faraday::Utils.default_params_encoder = Faraday::FlatParamsEncoder
username = ''
password = ''
term = ''
@shunfan
shunfan / slugify.py
Last active June 25, 2017 20:18
Slugify Chinese
# coding=utf-8
"""
Slugify for Chinese
没有优化多音字
优化多音字的项目有:
https://github.com/jiedan/chinese_pinyin
"""
import re
import unidecode
@shunfan
shunfan / nginx_overrides
Created November 7, 2017 04:14 — forked from sheharyarn/nginx.overrides
Restart / Reload Nginx without Entering Sudo Password
# 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

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 / git-snippets.sh
Last active August 20, 2018 20:04
Git Snippets
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