Skip to content

Instantly share code, notes, and snippets.

Avatar

simsicon

  • Alipay
  • Shanghai
View GitHub Profile
@simsicon
simsicon / source.list
Created Sep 5, 2013
A source.list for ubuntu 13.04 Raring
View source.list
deb http://mirrors.163.com/ubuntu/ raring main universe restricted multiverse
deb-src http://mirrors.163.com/ubuntu/ raring main universe restricted multiverse
deb http://mirrors.163.com/ubuntu/ raring-security universe main multiverse restricted
deb-src http://mirrors.163.com/ubuntu/ raring-security universe main multiverse restricted
deb http://mirrors.163.com/ubuntu/ raring-updates universe main multiverse restricted
deb http://mirrors.163.com/ubuntu/ raring-proposed universe main multiverse restricted
deb-src http://mirrors.163.com/ubuntu/ raring-proposed universe main multiverse restricted
deb http://mirrors.163.com/ubuntu/ raring-backports universe main multiverse restricted
deb-src http://mirrors.163.com/ubuntu/ raring-backports universe main multiverse restricted
deb-src http://mirrors.163.com/ubuntu/ raring-updates universe main multiverse restricted
@simsicon
simsicon / assertions.rb
Created Feb 13, 2014
capybara minitest assertions comments
View assertions.rb
##
# Assertion that there is button
#
# see Capybara::Assertions#refute_button
# see Capybara::Assertions#assert_no_button
# see Capybara::expectations#must_have_button
# see Capybara::expectations#wont_have_button
# :method: assert_button
##
@simsicon
simsicon / provisioning.sh
Created May 6, 2016
A provisioning script for Rails webapp on Ubuntu 14.04 LTS
View provisioning.sh
### Install Git and build deps
sudo apt-get update
sudo apt-get install software-properties-common tmux htop curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev libffi-dev tcl8.5
sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get install git
### Install rbenv and ruby
cd
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
@simsicon
simsicon / logrotate.conf
Created Mar 24, 2016
Helpful logrotate configuration
View logrotate.conf
/var/log/app.log {
weekly
missingok
rotate 52
compress
delaycompress
notifempty
copytruncate
}
View kmp.py
def kmp(text, pattern):
partial = [0]
for i in range(1, len(pattern)):
j = partial[i - 1]
while j > 0 and pattern[j] != pattern[i]:
j = partial[j - 1]
partial.append(j + 1 if pattern[j] == pattern[i] else j)
ret = []
View bst.py
import math
class Tree:
def __init__(self, seq):
self.root = seq[0]
self.left_seq, self.right_seq = [], []
if len(seq) == 1:
self.leaf = True
self.left = None
@simsicon
simsicon / mlm.md
Last active Jul 14, 2016
Machine Learning Machine, 2016-07, Under 2500 USD
@simsicon
simsicon / proc.rb
Created Nov 12, 2013
LocalJumpError
View proc.rb
def inner_proc
_proc = Proc.new {return 42}
puts _proc.call
end
def outter_proc(_proc)
puts _proc.call
end
inner_proc # => 42
@simsicon
simsicon / api
Created Oct 22, 2013
RESTful API examples for Grit
View api
Examples built with referenced from https://github.com/mojombo/grit/blob/master/lib/grit/repo.rb
POST /repos
PARAMS
bare: { type:Boolean, default:false }
repo_name: { type:String, required:true }
path: {type:String, required:true }
REQUEST EXMAPLE
{
"bare":true,
@simsicon
simsicon / fork_env.rb
Created Sep 22, 2013
ENV will inherit content from parent, not disturbed by siblings.
View fork_env.rb
ENV['p_name'] = 'master'
puts "[master] pid: #{Process.pid} pname: #{ENV['p_name']}"
p1 = Process.fork{
puts "[p1] pid: #{Process.pid} pname: #{ENV['p_name']}"
ENV['p_name'] = 'p1'
puts "[p1] pid: #{Process.pid} pname: #{ENV['p_name']}"
}
p2 = Process.fork{
You can’t perform that action at this time.