Skip to content

Instantly share code, notes, and snippets.

View cgallagher's full-sized avatar

Chris Gallagher cgallagher

View GitHub Profile
@cgallagher
cgallagher / gist:126391
Created June 9, 2009 09:51
Snippet to prevent IE from storing iFrames loaded after page load as being an additional entry in the browser history in Internet Explorer. (Also kills the "click" noise in IE6) - ported to jQuery from YUI Version: http://www.julienlecomte.net/blog/2007/1
function setIFrameSrc(iframe, src) {
var el;
iframe = $(iframe)
if ($.browser.msie) {
// Create a new hidden iframe.
el = $(iframe).clone();
$(el).css("position", "absolute");
$(el).css("visibility", "hidden");
// keep the original iframe id unique!
$(el).attr("id", "");
#generate an array of random numbers for a range
def ranGen(maxNum, quantity)
counter = 0
nums = Array.new
while counter < quantity
member = rand(maxNum)
nums << member
counter = counter + 1
require 'rubygems'
require 'scrobbler'
require 'net/http'
require 'uri'
require 'hpricot'
require 'cgi'
require 'dbi'
require 'fastercsv'
require 'rubygems'
require 'scrobbler'
require 'net/http'
require 'uri'
require 'hpricot'
require 'cgi'
require 'dbi'
require 'fastercsv'
@cgallagher
cgallagher / format_number_to_thousands.rb
Created November 4, 2009 16:27
Takes a flat number and uses a regex to format the commas
def self.formatViews(number)
number = number.gsub(/(\d)(?=\d{3}+(\.\d*)?$)/, '\1,')
number
end
# template.rb
# USAGE: rails -m http://gist.github.com/gists/115163.txt PROJECT_NAME
run "rm public/index.html"
plugin 'thinking_sphinx', :git => 'git://github.com/freelancing-god/thinking-sphinx.git'
plugin 'will_paginate', :git => 'git://github.com/mislav/will_paginate.git'
plugin 'factory_girl', :git => 'git://github.com/thoughtbot/factory_girl.git'
plugin 'paperclip', :git => 'git://github.com/thoughtbot/paperclip.git'
plugin 'project_search', :git => 'git://github.com/37signals/project_search.git'
plugin 'hubahuba', :git => 'git://github.com/paulca/hubahuba.git'
/*
$("#prev ~ sibling) doesnt seem to work in IE7 if the type both the prev and sibling element are of the same type. The examples on jQuery.com dont point this out.
(http://docs.jquery.com/Selectors/siblings#prevsiblings)
below is a workaround.
*/
@cgallagher
cgallagher / FB Feed Form
Created March 2, 2011 09:19
Generate a simple feed form using the Facebook JavaScript SDK
show_feed_form: function(share_message,share_name, share_caption, share_description, share_image_href, share_image_src, share_action_link_text, share_action_link_href, share_user_message_prompt, share_href, callback)
{
var publish = {
method: 'stream.publish',
message: "",
attachment: {
name: share_name,
caption: share_caption,
description: (
@cgallagher
cgallagher / fb_wallpost_with_js_sdk.js
Created March 11, 2011 11:46
Create a wallpost for a target user using the FB JavaScript SDK
send_wall_post_to_user: function(idx, facebook_id, message, user_message, post_name, post_description, post_image, post_caption)
{
var params = {};
params['message'] = user_message;
params['name'] = post_name;
params['description'] = post_description;
params['link'] = 'http://apps.facebook.com/irelandville_dev/';
params['picture'] = post_image;
params['caption'] = post_caption;
@cgallagher
cgallagher / get_friends.js
Created March 15, 2011 11:41
get facebook friends
get_friend_list: function(facebook_id, limit, order, callback)
{
var friends = FB.Data.query("SELECT first_name, pic_square, uid, last_name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1={0}) ORDER BY {1} LIMIT {2}", parseInt(facebook_id), order, limit);
friends.wait(function(friends){
callback(friends);
});
},