Skip to content

Instantly share code, notes, and snippets.

View champierre's full-sized avatar

Junya Ishihara champierre

View GitHub Profile
module Autotest::Growl
def self.growl title, msg, img="~/.autotest_icons/rails_ok.png", pri=0, sticky=""
msg += " at #{Time.now.strftime('%Y-%m-%d %H:%M:%S')}"
system "growlnotify -n autotest -H localhost --image #{img} -p #{pri} -m #{msg.inspect} #{title} #{sticky}"
end
Autotest.add_hook :ran_command do |at|
output = at.results.last.slice(/(\d+)\s+tests,\s*(\d+)\s+assertions,\s*(\d+)\s+failures,\s*(\d+)\s+errors/)
if output
if $~[3].to_i > 0 || $~[4].to_i > 0
#!/usr/bin/ruby
print "Specify dbname: "
dbname = gets.chomp
pids = `psql -U postgres -c "select procpid from pg_stat_activity where datname = '#{dbname}'"`.scan(/^\s+(\d+)$/)
pids.flatten.each do |pid|
print "Kill #{pid}?[yN] "
system "sudo kill -9 #{pid}" if gets.chomp.downcase == "y"
end
class TestPublisher < Facebooker::Rails::Publisher
def profile_update(user, profile_fbml)
send_as :profile
recipients user
from user
profile profile_fbml
profile_main profile_fbml
end
end
<fb:if-section-not-added section="profile">
<p>You need one more action to complete. Click the button below.</p>
<fb:add-section-button section="profile" />
</fb:if-section-not-added>
_translations = {
"OK": "OK",
"Now": "現在",
"Today": "今日",
"Clear": "閉じる"
}
Date.weekdays = $w("日 月 火 水 木 金 土");
Date.months = $w("1月 2月 3月 4月 5月 6月 7月 8月 9月 10月 11月 12月" );
Date.prototype.getAMPMHour = function() { hour=Date.padded2(this.getHours()); return (hour == null) ? 00 : (hour > 24 ? hour - 24 : hour ) }
Date.prototype.getAMPM = function() { return (this.getHours() < 12) ? "" : ""; }
Date.prototype.toFormattedString = function(include_time){
str = this.getFullYear() + '/' + Date.padded2(this.getMonth() + 1) + '/' +Date.padded2(this.getDate());
if (include_time) { hour=this.getHours(); str += " " + this.getAMPMHour() + ":" + this.getPaddedMinutes() }
return str;
}
CalendarDateSelect::FORMATS[:japanese] = {
:date => "%Y/%m/%d",
:time => " %H:%M",
:javascript_include => "format_japanese"
}
CalendarDateSelect.format = :japanese
if (this.options.get("buttons")) {
buttons_div.build("br");
buttons_div.build("span", {innerHTML: "&#160;"});
out << image_tag(image,
:alt => "カレンダーから入力",
:onclick => "new CalendarDateSelect( $(this).previous(), #{options_for_javascript(javascript_options)} );",
:style => 'border:0px; cursor:pointer;',
:class=>'calendar_date_select_popup_icon')
/*
Script that darken a hex color.
Released under the MIT license
Junya Ishihara <junya@champierre.com>
http://champierre.com
*/
function darken(hexstr, scalefactor) {