Skip to content

Instantly share code, notes, and snippets.

View bumi's full-sized avatar

Michael Bumann bumi

View GitHub Profile
@bumi
bumi / gist:20856
Created October 29, 2008 22:57
nice bash alias for git push origin master
# jan's gitpush alias: http://railslove.com/weblog/2008/10/28/git-push-it-origin-master/#comments
alias gitpush=\
'open http://www.youtube.com/watch?v=BCV5yGKWjv4; \
git push origin master'
#!/usr/bin/env ruby
#actually I just wanted to try forking a gist :D
exit unless ARGV.size == 1
pids = %x[ps ax|grep #{ARGV[0]}|grep -v grep].split("\n").map{|line| line.strip.scan(/^\d+/).first.to_i} - [Process.pid]
if pids.any?
system "kill #{pids.join(' ')}"
puts "killed #{pids.size} #{ARGV[0]} instance(s)"
@bumi
bumi / gist:27085
Created November 20, 2008 16:03
fakebug - don't let console.log break your code on browsers without firebug
var fakebug = function() {
var firebug_methods = ["log", "info", "debug", "warn", "error", "assert", "dir", "dirxml", "trace", "group", "groupEnd", "time", "timeEnd", "profile", "profileEnd", "count"];
window.console = {};
for(var i=0;i<firebug_methods.length;i++) {
window.console[firebug_methods[i]] = function() {};
}
};
if(!window.console) { fakebug(); }
@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"}