Skip to content

Instantly share code, notes, and snippets.

namespace :deploy do
def config(key)
(@config ||= YAML.load_file("config/deploy.yml").symbolize_keys)[key.to_sym]
end
# Hooks as needed
task :local_before do
end
=begin
http://groups.google.com/group/capistrano/msg/9f17c9c7787ac390
Message from discussion deploy:check and config.gem
From: Tom Copeland <t...@infoether.com>
Date: Thu, 4 Feb 2010 06:57:50 -0500
Local: Thurs, Feb 4 2010 3:57 am
Subject: Re: [capistrano] deploy:check and config.gem
On Feb 4, 2010, at 6:39 AM, Tom Copeland wrote:
# Instance methods can only access class-level instance variables via accessor methods (which are themselves class-level methods).
# Here's a demonstration of a more complex situation (in which the instance method in question comes from a mix-in module)
# that illustrates the same principle.
module M
def f
puts self.class.a
end
end
@HotFusionMan
HotFusionMan / passing_unknown_number_of_arguments_through_to_another_method.rb
Created August 12, 2010 00:12
passing_unknown_number_of_arguments_through_to_another_method.rb
class Parent
def initialize( a, b )
@a = a
@b = b
end
attr_reader :a, :b
end
class Child < Parent
def initialize( *args )
@HotFusionMan
HotFusionMan / initialize_is_not_a_class_method.rb
Created August 12, 2010 00:25
initialize_is_not_a_class_method.rb
# In Ruby, initialize is not a class method; it can't access
# class instance variables.
class C
@a = 1
def self.a
@a
end
def initialize
@HotFusionMan
HotFusionMan / toggle_network-interface_up-down.bash
Created September 27, 2010 17:18
toggle_network-interface_up-down.bash
#!/bin/bash
if (( $# < 1 ))
then
script_name=`basename $0`
echo "Usage: $script_name <interface_name>"
echo " e.g.: $script_name `ifconfig -l -d | cut -f 1 -d ' '`"
exit
fi
@HotFusionMan
HotFusionMan / toggle_Require_password_on_wake.scpt
Created October 26, 2010 02:29
When lending your Mac to someone who doesn't have an account on it, turn off being bothered to type in your password for them every time they have to wake it from sleep.
tell application "System Preferences"
activate
set current pane to pane id "com.apple.preference.security"
tell application "System Events"
tell process "System Preferences"
-- UNLOCK CHECKS
if (exists checkbox "Click the lock to make changes." of window 1) is true then
click checkbox "Click the lock to make changes." of window 1
@HotFusionMan
HotFusionMan / toggle_Require_password_on_wake.sh
Created October 27, 2010 15:34
shell script for calling gist 646214 from the command line
#!/bin/bash
~/bin/toggle_Require_password_on_wake.app/Contents/MacOS/applet
@HotFusionMan
HotFusionMan / NotImplementedError_bypasses_rescue_clause.rb
Created December 17, 2010 20:41
NotImplementedError bypasses rescue clause in Ruby 1.8.7 (REE)
# Tested under:
# $ ruby -v
# ruby 1.8.7 (2010-04-19 patchlevel 253) [i686-darwin10.4.0], MBARI 0x6770, Ruby Enterprise Edition 2010.02
class C
def f
raise NotImplementedError
end
end
@HotFusionMan
HotFusionMan / jEdit.rb
Created January 11, 2011 15:53
jEdit command line command for Mac OS X (strip off the .rb filename extension to make it look more like a typical Unix command line utility).
#!/usr/bin/env ruby
arguments = []
ARGV.each { |arg|
arguments << File.expand_path( arg )
}
system( "java -cp /Applications/jEdit.app/Contents/Resources/Java/jedit.jar:/System/Library/Java -Dapple.awt.textantialiasing=true -Dapple.laf.useScreenMenuBar=true -Dapple.awt.antialiasing=true org.gjt.sp.jedit.jEdit -background #{arguments.join( ' ' )} &" )