Skip to content

Instantly share code, notes, and snippets.

View mathias's full-sized avatar

Matt Gauger mathias

View GitHub Profile
@mathias
mathias / buttons.coffee
Created January 30, 2012 15:31
Haml + Coffeescript Tweet button and Like button
((d, s, id) ->
js = undefined
fjs = d.getElementsByTagName(s)[0]
return if d.getElementById(id)
js = d.createElement(s)
js.id = id
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1"
fjs.parentNode.insertBefore js, fjs
) document, "script", "facebook-jssdk"
Scenario: Requesting an invalid page
When I go to an invalid path
Then I should see a 404 page with a goat
@mathias
mathias / gist:1998841
Created March 8, 2012 05:09
shoes rake
mathiasx@banshee:~/dev/shoes (rake_refactor *)$ rake osx:deps:install
git remote add shoes https://github.com/wasnotrice/homebrew.git
From https://github.com/wasnotrice/homebrew
* [new branch] gh-pages -> shoes/gh-pages
* [new branch] master -> shoes/master
* [new branch] quartz -> shoes/quartz
* [new branch] shoes -> shoes/shoes
* [new branch] shoes-dev -> shoes/shoes-dev
gettext already exists, continuing
glib already exists, continuing
mathiasx@banshee:~/dev/shoes (rake_refactor)$ rake clean
mathiasx@banshee:~/dev/shoes (rake_refactor)$ rake osx:deps:install
git remote add shoes https://github.com/wasnotrice/homebrew.git
From https://github.com/wasnotrice/homebrew
* [new branch] gh-pages -> shoes/gh-pages
* [new branch] master -> shoes/master
* [new branch] quartz -> shoes/quartz
* [new branch] shoes -> shoes/shoes
* [new branch] shoes-dev -> shoes/shoes-dev
gettext already exists, continuing
@mathias
mathias / tomato.rb
Created May 23, 2012 15:59
SassyTomato Timer (for pomodoros)
Shoes.app :height => 185, :width => 215, :title => "SassyTomato" do
background white
@time_to_start = Time.new
@stopped = true
flow do
stack :margin => 10, :width => 75 do
image "http://i.imgur.com/NgtbE.jpg"
end
stack :margin => 10, :width => -75 do
button "Pomodoro" do
@mathias
mathias / foo_controller.rb
Created May 28, 2012 15:58
An idea for printing out available local variables and their attributes in a Rails view.
class FooController < ApplicationController
def index
@foo = Foo.find(params[:id])
@bar = Bar.find(params[:bar_id])
@locals = @foo + @bar # this line and the locals view stuff gets removed when you're done developing
end
end
@mathias
mathias / template.rb
Created July 5, 2012 18:59
Pretty Standard Rails Template
# >---------------------------------------------------------------------------<
#
# _____ _ _ __ ___ _
# | __ \ (_) | \ \ / (_) | |
# | |__) |__ _ _| |___\ \ /\ / / _ ______ _ _ __ __| |
# | _ // _` | | / __|\ \/ \/ / | |_ / _` | '__/ _` |
# | | \ \ (_| | | \__ \ \ /\ / | |/ / (_| | | | (_| |
# |_| \_\__,_|_|_|___/ \/ \/ |_/___\__,_|_| \__,_|
#
# This template was generated by RailsWizard, the amazing and awesome Rails
@mathias
mathias / gist:3112558
Created July 14, 2012 18:32
Run rake. Just run rake.
mathiasx@banshee:~/dev$ git clone git@github.com:mathias/geronimo.git
Cloning into 'geronimo'...
remote: Counting objects: 123, done.
remote: Compressing objects: 100% (82/82), done.
remote: Total 123 (delta 32), reused 114 (delta 23)
Receiving objects: 100% (123/123), 34.18 KiB, done.
Resolving deltas: 100% (32/32), done.
mathiasx@banshee:~/dev$ cd geronimo/
/Users/mathiasx/dev/geronimo
@mathias
mathias / chapter_2.clj
Created July 15, 2012 23:11
Land of Lisp Chapter 2
(ns chapter_2_clj.core)
; here I use atoms as a replacement for chapter 2's globals
(def small (atom 1))
(def big (atom 100))
(defn average [& all]
(quot (apply + all) (count all)))
; here's a version that uses arguments
@mathias
mathias / try_chain.rb
Created July 25, 2012 01:42 — forked from rbxbx/try_chain.rb
eeevil
class Object
def try_chain *meths
meths.inject(self) do |res, meth|
break unless result = res.try(meth)
result
end
end
end