Skip to content

Instantly share code, notes, and snippets.

View bumi's full-sized avatar

Michael Bumann bumi

View GitHub Profile
@bumi
bumi / retweeter.js
Created December 1, 2008 15:32
adds a nice RT button to the tweet action buttons that allows you to instantly retweet a post
ReTweeter = {
initialize: function() {
$(".status").each(function(count,status) {
var actions = $(status).find("td.actions div");
var link = $("<a/>").attr({href:"/home/?status="+ReTweeter.reTweetOf(status)});
link.append( $("<img/>").attr({src:"http://railslove.com/rt.gif", alt:"REtweet this"}) )
link.bind("click",function(e){
e.preventDefault();
var status = $(this).parents(".status");
$("#status").val(ReTweeter.reTweetOf(status));
@bumi
bumi / railslove.rb
Created December 25, 2008 23:00
the new railslove rails template. Kickstart your app
# RAILSLOVE.com template
#
# with help and ideas from:
# http://gist.github.com/33337 By Peter Cooper
# http://github.com/jeremymcanally/rails-templates/tree/master/suspenders.rb Suspenders by Thoughtbot Nathan Esquenazi
if yes?("symlink local rails copy to vendor?")
path = ask("what's the directory of your local rails copy?")
inside('vendor') { run "ln -s #{path} rails" }
on handle_string(tweet)
tell application "Keychain Scripting"
set twitter_key to first Internet key of current keychain whose server is "twitter.com"
set twitter_login to quoted form of (account of twitter_key & ":" & password of twitter_key)
end tell
set twitter_status to quoted form of ("status=" & tweet)
set results to do shell script "curl --user " & twitter_login & " --data-binary " & twitter_status & " http://twitter.com/statuses/update.json"
-- display dialog results
return nothing
end handle_string
# legacy User class to import users from a vbulletion database
class LegacyUser < LegacyModel
# important! please change:
self.model = User # which is the new Rails model
self.table_name = "vbulletin_user" # the vbulletin table name
# attribue mapping: {:rails => :vbulletin}
self.attribute_mapping = {:legacy_id => :userid, :name => :username, :email => :email, :password => :email, :password_confirmation => :email} # map old vbulletin attrbute names to new rails attribute names {:rails => :vbulletin}
attr_accessor *self.attribute_mapping.values
@bumi
bumi / resizing_text_area.js
Created March 3, 2009 13:35
// simple textarea resizing script for prototype
// simple textarea resizing script for prototype
var ResizingTextArea = Class.create({
min_height: 40,
rowHeight: 16,
padding: 4,
unit: "px",
initialize: function(field,options){
Object.extend(this,(options||{}));
this.element = $(field);
@bumi
bumi / Prototype wrapper for the YUI Uploader.js
Created April 21, 2009 14:10
A Prototype Wrapper for the Yahoo Uploader
Uploader = Class.create({
fileList: null,
handler: null,
uploaded:0,
allowMultipleFiles: true,
simUploadLimit: 1,
parameterName: "file",
filter: {
images:{description:"Images", extensions:"*.jpg;*.JPG;*.png;*.PNG"},
office:{description:"Office Document", extensions:"*.doc;*.DOC;*.docx;*.DOCX;*.xls;*.XLS;*.xlsx;*.XLSX;*.ppt;*.PPT;*.pptx;*.PPTX"}
hashed_result = ["a","b","a"].inject(Hash.new(0)) {|hash,value| hash[value]+=1; hash}
hashed_result.sort{|a,b| b[1] <=> a[1]}.collect{|e| e[0]}
before_filter :find_domain
def find_domain
if request.host == DEFAULT_HOST
redirect_to(frontpage_url) if request.path == "/"
return true
end
@domain = Domain.find_by_host(request.host)
redirect_to(frontpage_url( :host=> DEFAULT_HOST)) and return false unless @domain
instance_variable_set("@company".to_sym, @domain.company)