This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
function validate_contact_admin_form(form_id) { | |
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/; | |
var address = document.forms[form_id].elements['email'].value; | |
if(reg.test(address) == false) { | |
alert('Invalid Email Address'); | |
return false; | |
} | |
} | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'active_record' | |
ActiveRecord::Base.logger = Logger.new(STDERR) | |
ActiveRecord::Base.colorize_logging = false | |
ActiveRecord::Base.establish_connection( | |
:adapter => "sqlite3", | |
:dbfile => ":memory:" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cookies[:survey_user_id] = { :value => self.current_user.id.to_s, :expires => 1.year.from_now } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/ftp' | |
ftp=Net::FTP.new | |
ftp.connect(URL,21) | |
ftp.login(username,passwd) | |
ftp.chdir(directory) | |
ftp.getbinaryfile(filename) | |
ftp.close | |
http://ruby-doc.org/stdlib/libdoc/net/ftp/rdoc/index.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rails _2.2.2_ myapp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If your workers are inactive for a long period of time, they'll lose | |
# their MySQL connection. | |
# | |
# This hack ensures we re-connect whenever a connection is | |
# lost. Because, really. why not? | |
# | |
# Stick this in RAILS_ROOT/config/initializers/connection_fix.rb (or somewhere similar) | |
# | |
# From: | |
# http://coderrr.wordpress.com/2009/01/08/activerecord-threading-issues-and-resolutions/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
u = User.find(id) | |
u = u.becomes(u.type.constantize) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>> callback = Addressable::URI.parse("http://unni.com") | |
=> #<Addressable::URI:0x810ab0b4 URI:http://unni.com> | |
>> callback.query_values = callback.query_values ? callback.query_values.merge({"angry" => "birds"}) : {"angry" => "birds"} | |
=> {"angry"=>"birds"} | |
>> callback.to_s | |
=> "http://unni.com?angry=birds" | |
>> callback = Addressable::URI.parse("http://unni.com?nikhil=krishna") | |
=> #<Addressable::URI:0x8109fc8c URI:http://unni.com?nikhil=krishna> | |
>> callback.query_values = callback.query_values ? callback.query_values.merge({"angry" => "birds"}) : {"angry" => "birds"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo gem update --system 1.3.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rvm rubygems 1.3.5 |
OlderNewer