Skip to content

Instantly share code, notes, and snippets.

View mathias's full-sized avatar

Matt Gauger mathias

View GitHub Profile
say "You call me on my car phone with that je ne se quois
you say you need a little of my ooh la la
I know you get lonely in your canopy bed
well say no more baby, I'll be running everywhere
say no more
Mon Amour
I'll bring my lovin' right to your front door
here I come
baby je'ta dour
@mathias
mathias / gist:3895735
Created October 15, 2012 21:41
Don't jokingly put this in your app to make sure that you've booted up in JRuby
if defined? RUBY_ENGINE && RUBY_ENGINE == 'jruby'
`say jay roOoOoOoOoOob ee`
else
`say 'matz is nice so we are on on mri'`
end
# Redis configuration file example
# Note on units: when memory size is needed, it is possible to specify
# it in the usual form of 1k 5GB 4M and so forth:
#
# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
# 1g => 1000000000 bytes
I don't do:
<%= javascript_tag do %>
window.posts = <%= @posts.to_json %>
<% end %>
I do:
<div id="posts" data-url="<%= @posts %>">
And the view is smart enough to know to call to_json on it, works for collections
Also:
class SomeController < ApplicationController
def my_action
@things = [ {'name' => 'Matt'},
{'name' => 'Ashe'}]
end
end
@mathias
mathias / simple_app.js
Created March 9, 2013 18:37
Is this how people are using node/npm modules with CoffeeScript classes?
require('coffee-script');
var SimpleClass = require('./simple_class');
var simple_class = new SimpleClass;
console.log(simple_class.foo());
# lib/decent_exposure/draper_strong_parameters_strategy.rb:
class DraperStrongParametersStrategy < DecentExposure::StrongParametersStrategy
def resource
super.decorate
end
end
# app/controllers/articles.rb
@mathias
mathias / Gemfile
Last active December 16, 2015 18:29
Mad-Railers code kata night (2013-04-29): word chains kata
source "https://rubygems.org"
gem 'rspec'
@mathias
mathias / gist:5517685
Created May 4, 2013 14:40
Some notes from setting up a Vagrant for a Rails project:

Ubuntu precise64 box:

# Necessary software:
sudo apt-get install curl tmux vim

# Install RVM:
curl -L https://get.rvm.io | bash -s stable --autolibs=enabled
source /home/vagrant/.rvm/scripts/rvm
@mathias
mathias / minsky_circle_algorithm_glitches.rb
Created July 31, 2013 00:02
shoes minsky's circle algorithm animation glitches
Shoes.app do
epsilon = 1.0/16
offset = 250
initial_x = 100
initial_y = 100
fill red
@animate = animate (2) do |i|