Skip to content

Instantly share code, notes, and snippets.

View bunnymatic's full-sized avatar
💭
writing computer programs

Mr Rogers bunnymatic

💭
writing computer programs
View GitHub Profile
@bunnymatic
bunnymatic / db.rake
Created June 30, 2013 20:27
Using PGBackups, add tasks for pull from a heroku app and restore to local development database.
namespace :<MY APP NAMESPACE> do
namespace :db do
desc "Fetch the latest backup from heroku"
task :fetch => [:environment] do
app = ENV['app']
if app.blank?
puts "You must specify the heroku app name to get its database (use app=<appname>)"
else
url = `heroku pgbackups:url --app #{app}`
db_prefix = app.gsub('-','_')
@bunnymatic
bunnymatic / timezone_testing.rb
Last active December 11, 2015 17:38
Timezone Playtime
puts "Server Timezone: %s" % Rails.configuration.time_zone
# try with ruby 1.8.7/1.9.2
# try with different rails apps timezones
springtime = '04/25/2013 1:30PM'
falltime = '11/12/2013 2:40PM'
# maybe print the app timezone here
times = [[ :now , Time.now ],
[:now_zoned , Time.zone.now],
[:spring_parsed , Time.parse(springtime)],
[:spring_parsed_zoned , Time.zone.parse(springtime)],
@bunnymatic
bunnymatic / meteor
Last active December 10, 2015 09:49
new meteor shell script which alllows execution of node processes with easy access to the MeteorJS environment if it's run as meteor-exec. To make this work, replace /usr/local/meteor/bin/meteor with this file, and add a link from meteor-exec to this.
#!/bin/bash
BUNDLE_VERSION=0.2.8
# OS Check. Put here because here is where we download the precompiled
# bundles that are arch specific.
UNAME=$(uname)
if [ "$UNAME" != "Linux" -a "$UNAME" != "Darwin" ] ; then
echo "Sorry, this OS is not supported."
exit 1
@bunnymatic
bunnymatic / bash-completion-lunchy.bash
Created December 23, 2012 23:39
Bash completion script for mperham/lunchy gem
__from_lunchy_list() {
COMPREPLY=()
local cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=($(compgen -W '$(lunchy list)' -- $cur))
}
complete -F __from_lunchy_list -o default lunchy
@bunnymatic
bunnymatic / sayit.rb
Last active November 18, 2015 06:23
run all the mac voices with a phrase
#!/usr/bin/env ruby
voices = [
"Agnes",
"Kathy",
"Princess",
"Vicki",
"Victoria",
"Bruce" ,
"Fred" ,
@bunnymatic
bunnymatic / 0-readme.md
Created December 4, 2012 19:41 — forked from burke/0-readme.md
ruby-1.9.3-p327 cumulative performance patch for rbenv

ruby-1.9.3-p327 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

@bunnymatic
bunnymatic / query_string_parser.js
Created November 17, 2012 22:16
simple querystring parser in javascript using the DOM
var QueryStringParser;
QueryStringParser = (function() {
function QueryStringParser(url) {
var parser, _that;
this.query_params = {};
if (!document || !document.createElement) {
throw 'This needs to be run in an HTML context with a document.';
}
@bunnymatic
bunnymatic / gist:4050373
Created November 10, 2012 08:03
chunk a string into equal length parts
class String
def chunk(ct)
result = []
dup = self.dup
val = dup.slice!(0..(ct-1))
until val.empty? || !val do
result << val
val = dup.slice!(0..(ct-1))
end
result
@bunnymatic
bunnymatic / admin_form_builder.rb
Created November 1, 2012 02:38
Rails Form Helpers for Bootstrap
# in app/helpers/admin_form_builder.rb
class AdminFormBuilder < ActionView::Helpers::FormBuilder
####
# To control classes on fields, pass in the following in your options hash
# :row_class => 'whatever' : this will add a class 'whatever' to the field wrapper (which is a row)
# :input_html => {:class => 'whatever'} : this will add all these elements to the input/textarea tag as attributes
# Note: if you use the field_row method, this will be ignored
#
def file_input_row(field, hint, opts = {})
@bunnymatic
bunnymatic / jquery.my_plugin.js.coffee
Last active October 9, 2015 06:48
jquery plugin boilerplate in coffeescript Javascript version is here https://gist.github.com/bunnymatic/1048060
$.myPluginDefaults =
param1: 'default param1'
param2: []
$.fn.myPlugin = (method) ->
inArgs = arguments
methods =
init: (options) ->
localSettings = $.extend({},$.myPluginDefaults, options);