Skip to content

Instantly share code, notes, and snippets.

View michaeldwan's full-sized avatar
🍩

Michael Dwan michaeldwan

🍩
View GitHub Profile
>> redis = Redis.new
=> #<Redis client v2.0.3 connected to redis://127.0.0.1:6379/0 (Redis v1.2.6)>
>> redis.smembers('missing')
=> nil
>> redis.sadd('missing', 'hello')
=> true
>> redis.smembers('missing')
=> ["hello"]
@michaeldwan
michaeldwan / bundle_helper.rb
Created July 6, 2010 05:39
Snippet to include JQuery from Google in production and locally in dev
module BundleHelper
def javascript_dev(*sources)
output = ""
sources = sources.to_a
sources.each do |pair|
output << javascript_src_tag(Rails.env.development? ? "dev/#{pair[0]}" : pair[1], {})
end
output.html_safe
end
end
@michaeldwan
michaeldwan / heroku_deploy.rake
Created July 4, 2010 02:08
Simple Rake task for customizing deployment to Heroku
# List of environments and their heroku git remotes
ENVIRONMENTS = {
:staging => 'myapp-staging',
:production => 'myapp-production'
}
namespace :deploy do
ENVIRONMENTS.keys.each do |env|
desc "Deploy to #{env}"
task env do
This prints the caller of a method. Useful to see who the hell called a function that shan't be called:
console.debug(arguments.callee.caller.toString());
(function($){
$.fn.sticky = function () {
var toolbar = $(this);
var wrapper = $(this).wrap($('<div />', { id : toolbar.attr('id') + '-wrapper'})).parent();
$(this).width(wrapper.width());
wrapper.height($(this).outerHeight());
$(window).bind('scroll resize', function () {
toolbar.toggleClass('follow', !$.fn.sticky.isScrolledIntoView(wrapper));
});
class DirtyTrackingArray < Array
attr_accessor :dirty
def initialize
@dirty = false
end
def push(value)
@dirty = true
super
WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the -A option the
next time you run initdb.
Success. You can now start the database server using:
/usr/local/bin/postgres -D /usr/local/var/postgres
or
/usr/local/bin/pg_ctl -D /usr/local/var/postgres -l logfile start
#!/bin/bash
# chkconfig: 2345 98 02
# description: Starts and stops Solr production
# Calculate RAILS_ROOT as 2 directories above the current file
_script_name=`basename $0`
RAILS_ROOT=`pwd`/`echo $0 | sed -e s/$_script_name//`..
RAILS_ENV=$2
set -e