Skip to content

Instantly share code, notes, and snippets.

View snowyu's full-sized avatar

Riceball LEE snowyu

View GitHub Profile
@snowyu
snowyu / README.md
Created September 30, 2017 22:14 — forked from githubutilities/README.md
Shadowsocks proxy and ssh proxy

Shadowsocks Proxy

apt-get install python-pip
pip install shadowsocks

sudo ssserver -p 443 -k password -m aes-256-cfb --user nobody -d start
@snowyu
snowyu / README.md
Created March 13, 2017 10:31 — forked from magnetikonline/README.md
Using Dnsmasq with Ubuntu 16.04LTS/14.04LTS/12.04LTS for virtual machine web application testing.

Using Dnsmasq with Ubuntu for VM web application testing

When running virtual machines under a Linux host system for testing web apps in various browsers (e.g. Internet Explorer), I found it rather tedious having to continually tweak the hosts file within each VM for the purpose of adding entries pointing back to the host machine's development web server address.

Instead the steps below will setup Dnsmasq on a Ubuntu 16.04LTS, 14.04LTS or 12.04LTS host machine for the purpose of serving both it's own DNS queries and that of virtual machine guests. Dnsmasq will parse the /etc/hosts file on your host machine where we will keep a single set of DNS entires to our test web application(s).

@snowyu
snowyu / etcd_cluster.sh
Created December 10, 2016 03:09 — forked from jolestar/etcd_cluster.sh
Run etcd cluster by docker with custom network
docker network create etcd --subnet 172.19.0.0/16
docker run -d --name etcd0 --network etcd --ip 172.19.1.10 quay.io/coreos/etcd etcd \
-name etcd0 \
-advertise-client-urls http://172.19.1.10:2379,http://172.19.1.10:4001 \
-listen-client-urls http://0.0.0.0:2379,http://0.0.0.0:4001 \
-initial-advertise-peer-urls http://172.19.1.10:2380 \
-listen-peer-urls http://0.0.0.0:2380 \
-initial-cluster-token etcd-cluster-1 \
-initial-cluster etcd0=http://172.19.1.10:2380,etcd1=http://172.19.1.11:2380,etcd2=http://172.19.1.12:2380 \
@snowyu
snowyu / introrx.md
Created August 5, 2016 11:48 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@snowyu
snowyu / get-real-path.coffee
Last active September 5, 2015 23:00
nodejs check whether the file name is case-insensitive and get the real path for the case-insensitive file-system across os.
fs = require 'fs'
path= require 'path'
tmp = require 'tmp'
tmp.setGracefulCleanup()
folderIsInsensitive = (aFolder)->
aFolder ?= '.'
t = tmp.fileSync template:path.join aFolder, '_tmp-XXXXXXXXX'
result = fs.existsSync t.name.toUpperCase()
t.removeCallback()
@snowyu
snowyu / _usage
Last active January 3, 2016 13:39 — forked from subosito/_usage
curl https://raw.github.com/gist/3342482/57d1f618104185aa89044f934c4f86cb74e11553/rbenv-openshift.sh | bash
@snowyu
snowyu / postsql.sql
Created May 27, 2012 12:36
PostgreSQL as JSON Document Store
-- PostgreSQL 9.2 beta (for the new JSON datatype)
-- You can actually use an earlier version and a TEXT type too
-- PL/V8 http://code.google.com/p/plv8js/wiki/PLV8
-- JSON Types need to be mapped into corresponding PG types
--
-- Number => INT or DOUBLE PRECISION
-- String => TEXT
@snowyu
snowyu / Gemfile
Created March 11, 2012 04:30 — forked from nu7hatch/Gemfile
Padrino authentication with Warden
# ...
gem 'padrino-warden', :git => "git://github.com/zmack/padrino-warden.git"
gem 'authtools'
Warden::Strategies.add(:bcrypt) do
def valid?
params[:username] || params[:password]
end
def authenticate!
return fail! unless user = User.first(:username => params[:username])
if user.encrypted_password == params[:password]
success!(user)
# Validates whether the value of the specified attribute matches the format of an URL,
# as defined by RFC 2396. See URI#parse for more information on URI decompositon and parsing.
#
# This method doesn't validate the existence of the domain, nor it validates the domain itself.
#
# Allowed values include http://foo.bar, http://www.foo.bar and even http://foo.
# Please note that http://foo is a valid URL, as well http://localhost.
# It's up to you to extend the validation with additional constraints.
#
# class Site < ActiveRecord::Base