Skip to content

Instantly share code, notes, and snippets.

@bomberstudios
bomberstudios / profile.sh
Created August 28, 2008 09:34
My .bash_profile
##### EXPORTS ################################################################
export PATH=/opt/local/bin:/opt/local/sbin:$HOME/bin:$PATH
export LC_CTYPE=en_US.UTF-8
# Editors
export EDITOR='mate -w'
export SVN_EDITOR='mate -w'
export GIT_EDITOR='mate -w'
# for Editor Kicker: http://editorkicker.rubyforge.org/
export EDITOR_KICKER="mate -l %s '%s'"
/* syntax.css for pygments */
/* from http://github.com/mojombo/tpw/blob/master/css/syntax.css */
.highlight { background: #ffffff; }
.highlight .c { color: #999988; font-style: italic } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { font-weight: bold } /* Keyword */
.highlight .o { font-weight: bold } /* Operator */
.highlight .cm { color: #999988; font-style: italic } /* Comment.Multiline */
.highlight .cp { color: #999999; font-weight: bold } /* Comment.Preproc */
// The `quickEach` method will pass a non-unique jQuery instance
// to the callback meaning that there will be no need to instantiate
// a fresh jQuery instance on each iteration. Most of the slow-down
// inherent in jQuery's native iterator method (`each`) is the constant
// need to have access to jQuery's methods, and so most developers
// see constructing multiple instances as no issue... E.g.
// $(...).each(function(){ $(this)... $(this)... $(this)... });
// A better approach would be `quickEach`.
jQuery.fn.quickEach = (function(){
@yuri-ko
yuri-ko / haproxy_nodejs_websocket
Created October 18, 2010 14:30
haproxy config to work with miksago's node-websocket-server
global
maxconn 4096
user haproxy
group haproxy
debug
defaults
timeout client 60000
timeout server 30000
timeout connect 4000
@jferris
jferris / new.rb
Created November 5, 2010 18:23
New FactoryGirl definition syntax
FactoryGirl.define do
sequence :email do |n|
"user#{n}@example.com"
end
factory :user do
email
password "test"
aliased_as :author
end
@samir
samir / gist:707798
Created November 20, 2010 12:51
Base for create .bash_profile for OS X
# --------------------------------------------------------
export APXS2=`which apxs`
export CFLAGS="-arch x86_64 -O2"
export ARCHFLAGS="-arch x86_64"
export EDITOR='mate -w'
export CLICOLOR=1
export TERM=xterm-color
export LSCOLORS=DxGxcxdxCxegedabagacad
export LC_CTYPE=en_US.UTF-8
@potatosalad
potatosalad / hashquiz.rb
Created December 31, 2010 04:36
Ruby quiz for convert hash "dot paths" into actual hash hierarchy.
#require 'rubygems'
require 'pp'
#require 'ap' # Awesome Print
class Object
# expects [ [ symbol, *args ], ... ]
def recursive_send(*args)
args.inject(self) { |obj, m| obj.send(m.shift, *m) }
end
end
@guilleiguaran
guilleiguaran / acceptance_helper.rb
Created February 28, 2011 20:41
RSpec+Capybara acceptance test example
# acceptance/acceptance_helper.rb
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
# Put your acceptance spec helpers inside /spec/acceptance/support
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
@dhh
dhh / gist:1014971
Created June 8, 2011 18:09
Use concerns to keep your models manageable
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end
@granoeste
granoeste / gist:1026558
Created June 15, 2011 05:55
[Android][WiFi]Wi-Fi Scan Results
final WifiManager mWifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
if(mWifiManager.getWifiState() == WifiManager.WIFI_STATE_ENABLED) {
// register WiFi scan results receiver
IntentFilter filter = new IntentFilter();
filter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);
registerReceiver(new BroadcastReceiver(){
@Override