Skip to content

Instantly share code, notes, and snippets.

View samnang's full-sized avatar
🚀

Samnang Chhun samnang

🚀
View GitHub Profile
worker_processes 3 # amount of unicorn workers to spin up
timeout 30 # restarts workers that hang for 30 seconds
preload_app true
GC.respond_to?(:copy_on_write_friendly=) and
GC.copy_on_write_friendly = true
before_fork do |server,worker|
defined?(ActiveRecord::Base) and
1. Why use VIM?
VIM rocks!
VI or VIM?
I hate the mouse!
I am a text person
I love touch-typing (huh - what is touch typing% again..)
You have production server with only SSH access!
2. Vim -- you already knew
Command mode & Insert mode
class A
end
puts "--" + A.instance_methods(false).join(', ')
class A
def otro
end
end
@samnang
samnang / ruby-1.9-tips.rb
Created February 4, 2011 01:08 — forked from igrigorik/ruby-1.9-tips.rb
0 Ruby 1.9 Tips, Tricks & Features:
def tip(msg); puts; puts msg; puts "-"*100; end
#
# 30 Ruby 1.9 Tips, Tricks & Features:
# http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/
#
tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2"
tip "Ruby 1.9 supports named captures in regular expressions!"
@samnang
samnang / a.rb
Created March 5, 2011 03:23 — forked from zzak/a.rb
class A
@@a = 1
@a = 2
a = 3
end
@samnang
samnang / .irbrc
Created March 9, 2011 06:59 — forked from jsmestad/.irbrc
# Make gems available
require 'rubygems'
# http://drnicutilities.rubyforge.org/map_by_method/
begin
require 'map_by_method'
rescue LoadError
puts "map_by_method is not installed. To enable, run: gem install map_by_method"
end
Then /^(?:|I )should see "([^\"]*)"(?: within "([^\"]*)")?$/ do |text, selector|
with_scope(selector) do
if defined?(Spec::Rails::Matchers)
page.should have_xpath("//*[text()='#{text}']", :visible => true)
else
assert page.has_xpath("//*[text()='#{text}']", :visible => true)
end
end
end
@samnang
samnang / users.md
Created June 29, 2011 17:54 — forked from jordanbyron/users.md
Discussion and design ideas for University Web's User API

le API design

A consumer needs to lookup a single user by their github name (jordanbyron). That consumer doesn't know the user's ID. There is a possibility to also search by email and twitter.

"/users.json?github=jordanbyron"
=> [{github: "jordanbyron", id: 1}]

When there are no results an empty array is returned

"/users.json?github=noexist"

require 'test/unit/assertions'
include Test::Unit::Assertions
assert_equal "1.9.2", RUBY_VERSION
# A Ruby meta-programming puzzle for polite programmers.
# This puzzle was created by Matt Wynne (@mattwynne) on 2011-04-10 inspired by Jim Weirich's
# talk at the Scottish Ruby Conference 2011.
#
# The challenge is: you have a class Foo which you want to monkey-patch, but politely.
@samnang
samnang / thinking_sphinx)
Created August 20, 2011 14:12 — forked from ancorcruz/thinking_sphinx)
Thinking Sphinx init.d script
#!/bin/bash -e
### BEGIN INIT INFO
# Provides: thinking_sphinx
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/stop Sphinx daemon for Thinking Sphinx
### END INIT INFO
CONFIG_FILE=/etc/default/thinking_sphinx.conf
. $CONFIG_FILE || exit