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')
// http://www.jittuu.com/2012/2/14/Testing-XPath-In-Chrome/
// 0. XPath Examples.
// More: http://xpath.alephzarro.com/content/cheatsheet.html
'//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 }
end
def bar
case @var
when 1
print [1..42]
@shunwen
shunwen / ssl_puma.sh
Created Jun 24, 2017 — forked from tadast/ssl_puma.sh
localhost SSL with puma
View ssl_puma.sh
# 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
File.open("tmp/pids/workers.pid", "a") {|f| f.puts Process.pid }
# Go daemon and disconnect from STDOUT/STDERR
@shunwen
shunwen / .kitchen.yml
Created Dec 2, 2014
chef apache cookbook test
View .kitchen.yml
---
driver:
name: docker
socket: <%= ENV['DOCKER_HOST'] %>
provisioner:
name: chef_zero
platforms:
- name: ubuntu-14.04
@shunwen
shunwen / rename_files.sh
Created Oct 29, 2014
Rename *.conf to *.conf.erb
View rename_files.sh
for f in *.conf
do
mv ${f}{,.erb}
done
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
shunwen / Dockerfile
Created May 21, 2014
Dockerfile Rails
View Dockerfile
FROM ubuntu:14.04
MAINTAINER Shunwen Hsiao, "https://github.com/shunwen"
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 = Logger.new(STDOUT)
View pattern_i_dont_understand.rb
class Foo
def self.do_something *args
new(args).do_something
end
def initialize *args
# set instance variables
@var1 = args[0]
# and so on
end
You can’t perform that action at this time.