Skip to content

Instantly share code, notes, and snippets.

View jeremywrowe's full-sized avatar
❤️
Coding

Jeremy W. Rowe jeremywrowe

❤️
Coding
View GitHub Profile
@jeremywrowe
jeremywrowe / items_controller.rb
Created November 1, 2012 03:15
DRY controller...
class ItemsController < ApplicationController
def index
@items = Item.all
end
def create
@item = Item.new(allowable_params)
update_or_create @item, :save
end
module ModuleExtensions
refine String do
def foo
puts "bar"
end
end
end
class Poop
@jeremywrowe
jeremywrowe / keyword_arguments.rb
Created November 11, 2012 05:23
keyword arguments ruby 2.0 with defaults
def something_fun(dump: "truck", tree: "hugger")
puts "#{dump} #{tree}"
end
something_fun
@jeremywrowe
jeremywrowe / ember_controller_inheritance.js
Created January 21, 2013 20:48
Controller Inheritance, Ember, and me.
RoflCopter.ApplicationController = Ember.Controller.extend({
sharedBehavior: function() {
return "A winner is you!!!";
}.property()
});
RolfCopter.AnotherController = RoflCopter.ApplicationController.extend({
importantStuff: function() {
var ohBeehave = this.get("sharedBehavior");
@jeremywrowe
jeremywrowe / routs_rails_console.rb
Created April 5, 2013 14:37
routes in rails console
include ActionDispatch::Routing
include Rails.application.routes.url_helpers
@jeremywrowe
jeremywrowe / cucumber_leaks.rb
Last active December 15, 2015 20:41
Show leaked instance variables in cucumber. A terrible hack but sometimes that is what ya need to do :)
$cucumber_instance_variables = []
Before do
$cucumber_instance_variables = instance_variables
end
After do
test_variables = instance_variables - $cucumber_instance_variables
message = "[WARN] the following test variables could be leaking #{leaked_variables.join(', ')}"
@jeremywrowe
jeremywrowe / too_legit.c
Last active August 11, 2016 17:52
Bringing goto statements in c back into style.
#include <stdlib.h>
#include <stdio.h>
#define too goto
int main( int argc, const char* argv[]) {
int times;
times = 0;
legit:
printf(" too legit,");
@jeremywrowe
jeremywrowe / gist:5373873
Last active December 16, 2015 03:59
Do you want to get onto your recent branchies easy? Here - ya - go. Create a new file named whatever you want, make it executable and put it in your path. From there go to your favorite project that you are working on type in whatever you named the script, and you are off to the races.
#!/usr/bin/env ruby
trap("INT") { puts "\ncatch'ya later"; exit 0 }
output = `git for-each-ref --count=10 --sort=-committerdate refs/heads/ --format='%(refname:short)'`
branches = output.split("\n")
unless option = ARGV[0]
puts <<-MSG
migrate () {
local zeus_command=""
if _zeus-installed
then
zeus_command="zeus"
fi
$zeus_command rake db:migrate && $zeus_command rake db:rollback && $zeus_command rake db:migrate && $zeus_command rake db:test:prepare
}
class Message
MAX_LENGTH = 240
...
end