Skip to content

Instantly share code, notes, and snippets.

View ashirazi's full-sized avatar

Arild Shirazi ashirazi

  • Washington D.C.
View GitHub Profile
#!/usr/bin/env ruby
require 'uri'
ARGV.each do |url|
puts URI.encode url
end
#!/usr/bin/env ruby
require 'uri'
ARGV.each do |url|
puts URI.decode url
end
@ashirazi
ashirazi / gist:4424177
Created January 1, 2013 00:33
String#strptime Ruby needs symmetry for Time#strftime. If a Time can be converted to a string (given a pattern), then a String should be convertible to a Time.
# This really should belong in String, not Date...
class String
# Calculate the Time represented by this string, and the (optional) time pattern
# that describes this string (see Time#strftime).
# Returns a nil time if the String does not match the pattern, or the pattern is invalid.
def strptime(format=nil)
date = format ? Date.strptime(self, format) : Date.strptime(self)
date.to_time
rescue
@ashirazi
ashirazi / .irbrc
Created July 19, 2012 18:54
pry instead of irb (everywhere including 'bundle console', 'rails console', 'irb')
# put this in your ~/.irbrc
begin
require 'pry'
Pry.start
exit
rescue LoadError
puts "Pry not found, using 'irb' instead. Try\n gem install pry"
end
@ashirazi
ashirazi / JQuery Multi Click README
Last active September 25, 2015 15:38 — forked from bokmann/README
Treat multiple clicks as single-click in browsers
Code
// Treat double-click like a single-click
$("button").multi_click(function () {
alert("It's all good.")
})
// Different actions for single- or double-click
$("button").multi_click(function () {
alert("Try double-clicking me!")