Skip to content

Instantly share code, notes, and snippets.

// in case using alongside prototype
var $j = jQuery.noConflict();
$j(document).ready(function()
{
// apply the disable onclick for buttons with css class of 'disable-on-click'
$j(".disable-on-click").bind('click', function(e) {
$j(this).attr("disabled", "true").attr("value", "Please wait...");
});
}
-- mssql 2000
SELECT db_name(dbid), *
FROM master.dbo.sysaltfiles
ORDER BY size DESC
-- mssql 2005 and above (untested)
SELECT db_name(database_id) database_name, *
FROM sys.master_files
# before the work-around
class Widget
end
# after the work-around
require 'base64'
class Widget
# override the rails attribute (getter)
def name
Base64::decode64(self[:name])
class CreateWidgets < ActiveRecord::Migration
def self.up
create_table :widgets do |t|
t.string :name, :limit => 255, :null => false
t.timestamps
end
end
def self.down
drop_table :widgets
# this worked as expected on mysql
# on postgresql it created a new widget with id of 0
def some_method
widget = Widget.find_or_initialize_by_id(params[:widget_id])
# ...
end
# workaround code for postgresql
def some_method
widget = Widget.find_or_initialize_by_id(params[:widget_id])
#!/bin/bash
directory="/home/YOUR_USER_NAME/projects/YOUR_PROJECT_DIR/trunk"
command="script/server"
title_dev="Dev_Trunk"
title_running="Running_Trunk"
profile2="P2"
firefox_profile="p2"
clear
echo ""
ln -s /home/YOUR_USER_NAME/scripts/launch_YOUR_PROJECT.sh launch_YOUR_PROJECT
EXEC dbo.sp_help_job @execution_status = 0;
@house9
house9 / gist:172342
Created August 21, 2009 19:17
ApplicationController#handler_exception
class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
# ...
rescue_from Exception, :with => :handler_exception
# ...
def handler_exception(exception)
if request.xhr? then
message = "Error: #{exception.class.to_s}"
message += " in #{request.parameters['controller'].camelize}Controller" if request.parameters['controller']