Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 )
# 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
=begin
http://groups.google.com/group/capistrano/msg/9f17c9c7787ac390
Message from discussion deploy:check and config.gem
From: Tom Copeland <[email protected]>
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:
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