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
# | |
# <%= form.select_time :start, :meridian => true %> | |
# | |
module ActionView | |
module Helpers | |
class DateTimeSelector | |
def select_time_with_meridian | |
html = select_time_without_meridian | |
if @options[:meridian] | |
id = input_id_from_type(:hour) |
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
// a helper function to create more dynamic object literals | |
// $h('key'+i, value) => { key1: value } | |
var $h = function() { | |
var constructor = function() { | |
var k = null, args = arguments[0]; | |
for (var i = 0; i < args.length; i++) { | |
if (k == null) { | |
k = args[i]; | |
} else { | |
this[k] = args[i]; |
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
var editor = new Ajax.InPlaceEditor('chart_name', '', { | |
okControl: false, | |
cancelControl: false, | |
submitOnBlur: true, | |
highlightcolor: 'transparent' | |
}); | |
// override the bound submit handler function to prevent | |
// the control from actually submitting to a url and instead | |
// do something more useful with the edit. | |
editor._boundSubmitHandler = function(e) { |
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
def self.max_allowed_packet | |
r = connection.execute "SHOW GLOBAL VARIABLES LIKE 'max_allowed_packet'" | |
r.fetch_row.last.to_i rescue 128.megabytes | |
end | |
validates_length_of :data, :in => 1 .. max_allowed_packet, | |
:allow_blank => true | |
validates_length_of :file, :in => 1 .. max_allowed_packet, | |
:allow_blank => true |
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"> | |
document.observe('dom:loaded', function() { | |
var li = new Element('li').update('li'); | |
$('a').update(li); | |
var killIE = true; | |
if (killIE) { | |
li.update('new name'); | |
} else { | |
$('a').update(); |
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
--- a/public/javascripts/application.js | |
+++ b/public/javascripts/application.js | |
@@ -70,9 +70,15 @@ | |
if (this.input && $F(this.input)) | |
this.positionThumb(parseFloat($F(this.input)) * this.width / 100); | |
- this.div.observe('mousedown', this.onMouseDown.bindAsEventListener(this)); | |
- this.div.observe('mouseup', this.onMouseUp.bindAsEventListener(this)); | |
- this.div.observe('mousemove', this.onMouseMove.bindAsEventListener(this)); | |
+ if (Prototype.Browser.MobileSafari) { |
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
# login to jabber/gtalk and have your computer say whatever people are saying to you | |
require 'rubygems' | |
require 'xmpp4r/client' | |
include Jabber | |
# settings | |
if ARGV.length != 2 | |
puts "Run with ./echo_thread.rb user@server/resource password" | |
exit 1 |
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
function fish_prompt --description 'Write out the prompt' | |
set git_sha (git rev-parse --short HEAD 2>/dev/null) | |
set git_branch (git rev-parse --abbrev-ref HEAD 2>/dev/null) | |
set git " $git_sha $git_branch " | |
if [ $git = ' ' ] | |
set git '' | |
end | |
set length (echo [ 00:00 AM -$git(prompt_pwd) ] | wc -c | tr -d ' ') | |
set fill (printf '%*s\n' (math (tput cols)-$length) '' | tr ' ' –) |
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 'rubygems' | |
require 'scrubyt' | |
google_data = Scrubyt::Extractor.define do | |
fetch 'http://www.google.com/search?hl=en&q="guarded by a dragon"' | |
excerpt "//div[@class=s]" | |
next_page '//td/a', :limit => ARGV.shift.to_i || 3 | |
end |
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 'rubygems' | |
require 'open-uri' | |
require 'json' | |
url = 'http://twitter.com/statuses/user_timeline.json?id=visnup&count=3200' | |
dates = open(url) { |f| JSON.parse f.read }.map { |e| Date.parse e['created_at'] } | |
sum = dates.inject(Hash.new(0)) { |s, t| s[t] += 1; s } | |
sum.keys.sort.each { |k| puts "#{k} (#{sum[k]}) #{'=' * sum[k]}" } |
OlderNewer