Skip to content

Instantly share code, notes, and snippets.


shunwen shunwen

Block or report user

Report or block shunwen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View xpath-cheatsheet.js
// XPath CheatSheet
// To test XPath in your Chrome Debugger: $x('/html/body')
// 0. XPath Examples.
// More:
'//hr[@class="edge" and position()=1]' // every first hr of 'edge' class
View snippet.rb
def foo
some_function(true, { :before => {a: 1},
:after => {b: 2} })
call_block { do_something }
def bar
case @var
when 1
print [1..42]
shunwen /
Created Jun 24, 2017 — forked from tadast/
localhost SSL with puma
# 1) Create your private key (any password will do, we remove it below)
$ cd ~/.ssh
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
View worker_skeleton.rb
class TestWorker
def startup
# Change process name
$PROGRAM_NAME = "HL7 - noop working..."
# Create pid file"tmp/pids/", "a") {|f| f.puts }
# Go daemon and disconnect from STDOUT/STDERR
shunwen / .kitchen.yml
Created Dec 2, 2014
chef apache cookbook test
View .kitchen.yml
name: docker
socket: <%= ENV['DOCKER_HOST'] %>
name: chef_zero
- name: ubuntu-14.04
shunwen /
Created Oct 29, 2014
Rename *.conf to *.conf.erb
for f in *.conf
mv ${f}{,.erb}
View flickrdl.rb
require 'flickraw'
require 'mini_magick'
require 'parallel'
def get_photo_urls_from_photoset(flickr, photoset_id)
total_pages = nil
current_page = 1
urls = []
opts = {
photoset_id: photoset_id,
shunwen / Dockerfile
Created May 21, 2014
Dockerfile Rails
View Dockerfile
FROM ubuntu:14.04
MAINTAINER Shunwen Hsiao, ""
RUN apt-get update
RUN apt-get install -qy git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common vim
RUN apt-get clean
# Install nodejs for js runtime
RUN add-apt-repository ppa:chris-lea/node.js
View poly_association_reference.rb
# Activate the gem you are reporting the issue against.
gem 'activerecord', '4.1.1'
require 'active_record'
require 'minitest/autorun'
require 'logger'
# This connection will do for database-independent bug reports.
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
ActiveRecord::Base.logger =
View pattern_i_dont_understand.rb
class Foo
def self.do_something *args
def initialize *args
# set instance variables
@var1 = args[0]
# and so on
You can’t perform that action at this time.