Skip to content

Instantly share code, notes, and snippets.

View plukevdh's full-sized avatar
🔥

Luke van der Hoeven plukevdh

🔥
View GitHub Profile
person = Person.new
person.name
person.setName(name)
person.setFirstName(first, lastName:last)
@plukevdh
plukevdh / gist:208541
Created October 12, 2009 16:56
Example of named parameters in macruby
NSApp.beginSheet(@info_sheet,
modalForWindow:@main_window,
modalDelegate:self,
didEndSelector:nil,
contextInfo:nil)
@plukevdh
plukevdh / customer_update_info_test.rb
Created November 5, 2009 15:15
Quick unit test customer safety. This way I'm not overwriting data by accident.
def setup
@cus_save = Customer.find("####")
login
end
def teardown
cus = Customer.find "####"
cus.attributes = @cus_save.attributes
assert cus.save!
@plukevdh
plukevdh / gist:227115
Created November 5, 2009 15:22
Quick way to throw errors to a list for display
def format_validations(object)
error_msg = "Error inputting user: <ul>"
error_msg << object.errors.map { |msg| "<li> #{msg.last} </li>"}.join(" ")
error_msg << "</ul>"
end
flash[:notice] = format_validations(data)
@plukevdh
plukevdh / gist:227117
Created November 5, 2009 15:23
cool way to display flash messages with rjs
page.visual_effect :appear, :flash_notice
page.delay(10.0) do
page.visual_effect :fade, :flash_notice
end
@plukevdh
plukevdh / gist:232161
Created November 11, 2009 18:15
Allows confirmation page parameter passing to only pass changed values and lets us pull the values back out to the customer attributes.
# grabs the changed hash and maps it to a flat hash containing just the updated params
@customer.attributes = Hash[*(params[:customer].map{|k,v| [k, v.last]}.flatten)]
@plukevdh
plukevdh / version_info.rb
Created November 16, 2009 21:48
Easy way to track versions and even display the svn revision number
module VersionInfo
#Version number file
MAJOR_VERSION = 1
ENHANCE_VERSION = 3
FIX_VERSION = 2
BETA_FLAG = true
RC_FLAG = false
def self.get_svn_revision
`svn info`.split("\n")[4][/\d+/].to_i
@plukevdh
plukevdh / failoverd.rb
Created December 15, 2009 04:48
Quick and to the point IP Failover
#!/usr/local/bin/ruby
#
# File: failoverd.rb
# Description: Daemon to handle failover and restart
# Date: 12-14-2009 - Luke van der Hoeven
#
# Credit: Based on Patrick Hennessy's ipfaild.pl script
# (http://git.pathennessy.com/cgi-bin/gitweb.cgi?p=linux-scripts.git;a=blob;f=ipfaild.pl;hb=HEAD)
#
@plukevdh
plukevdh / template_grab.rb
Created December 15, 2009 19:25
Web page scrubbing util to pull content from a main non-Rails driven site and create a template from it.
#!/usr/bin/ruby
require 'rubygems'
require 'hpricot'
require 'yaml'
require 'open-uri'
site = "http://www2.hargray.com"
settings = YAML::load( File.open("template_options.yml") )
@plukevdh
plukevdh / version_info.rb
Created January 8, 2010 19:33
VersionInfo module for handling versioning for apps
module VersionInfo
#Version number file
MAJOR_VERSION = 1
ENHANCE_VERSION = 4
FIX_VERSION = 0
BETA_FLAG = true
RC_FLAG = false
def self.get_svn_revision
`svn info`.split("\n")[4][/\d+/].to_i