Skip to content

Instantly share code, notes, and snippets.

View pigoz's full-sized avatar
:octocat:

Stefano Pigozzi pigoz

:octocat:
View GitHub Profile
This example shows how to setup an environment running Rails 3 under 1.9.2 with a 'rails3' gem set.
∴ rvm update --head
# ((Open a new shell)) or do 'rvm reload'
# If you do not already have the ruby interpreter installed, install it:
∴ rvm install 1.9.2
# Switch to 1.9.2-head and gemset rails3, create if it doesn't exist.
∴ rvm --create use 1.9.2@rails3
@tenderlove
tenderlove / person_test.rb
Created February 10, 2011 23:04
Use minitest/spec with Rails 3
require 'test_helper'
require 'minitest/autorun'
module Tenderlove
class Spec < MiniTest::Spec
include ActiveSupport::Testing::SetupAndTeardown
include ActiveRecord::TestFixtures
alias :method_name :__name__ if defined? :__name__
self.fixture_path = File.join(Rails.root, 'test', 'fixtures')
@jicksta
jicksta / gist:1001736
Created June 1, 2011 03:19
Jasmine shared behavior for asserting that a certain event on an element exposed as a Backbone view property properly executes the expected view instance method
function assertViewAction(viewClass, eventCallbackName, elementAccessorName, eventName, viewReference) {
it("should run the " + eventCallbackName + " action when the " + elementAccessorName + " gets a " + eventName + " event (assertViewAction)", function() {
var isPrototypal = eventCallbackName in viewClass.prototype;
if (isPrototypal) {
spyOn(viewClass.prototype, eventCallbackName);
}
var view = viewReference();
if (!isPrototypal) {
spyOn(view, eventCallbackName);
}
@burke
burke / 0-readme.md
Created January 27, 2012 13:44 — forked from funny-falcon/cumulative_performance.patch
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.

-> % vagrant status
/home/tyler/.rvm/gems/ruby-1.9.3-p0@infra-puppet/gems/vagrant-1.0.0/lib/vagrant/driver/virtualbox.rb:26:in `initialize': wrong number of arguments (0 for 1) (ArgumentError)
from /home/tyler/.rvm/gems/ruby-1.9.3-p0@infra-puppet/gems/vagrant-1.0.0/lib/vagrant/vm.rb:136:in `new'
from /home/tyler/.rvm/gems/ruby-1.9.3-p0@infra-puppet/gems/vagrant-1.0.0/lib/vagrant/vm.rb:136:in `rescue in reload!'
from /home/tyler/.rvm/gems/ruby-1.9.3-p0@infra-puppet/gems/vagrant-1.0.0/lib/vagrant/vm.rb:128:in `reload!'
from /home/tyler/.rvm/gems/ruby-1.9.3-p0@infra-puppet/gems/vagrant-1.0.0/lib/vagrant/vm.rb:35:in `initialize'
from /home/tyler/.rvm/gems/ruby-1.9.3-p0@infra-puppet/gems/vagrant-1.0.0/lib/vagrant/environment.rb:430:in `new'
from /home/tyler/.rvm/gems/ruby-1.9.3-p0@infra-puppet/gems/vagrant-1.0.0/lib/vagrant/environment.rb:430:in `block in load_vms!'
from /home/tyler/.rvm/gems/ruby-1.9.3-p0@infra-puppet/gems/vagrant-1.0.0/lib/vagrant/environme

Routing in Ember

In Ember, the application's state manager handles routing. Let's take a look at a simple example:

App.stateManager = Ember.StateManager.create({
  start: Ember.State.extend({
    index: Ember.State.extend({
      route: "/",
@sowawa
sowawa / sinachiku.rb
Created June 18, 2012 07:00 — forked from mattn/sinachiku.rb
sinatra on mruby
require 'HTTP'
require 'UV'
module Sinachiku
@routes = { 'GET' => [], 'POST' => [] }
def self.route(method, path, opts, &block)
@routes[method] << [path, opts, block]
end
def self.do(r)
@routes[r.method].each {|path|
@morgoth
morgoth / layout_filter.rb
Created July 10, 2012 18:29
Layout filter for rake-pipeline
# Support for rendering views in layout
# Example usage in Assetfile:
#
# match "views/*.md" do
# markdown
# layout path: "app/views/layout.erb"
# concat { |input| input.sub(%r{views/}, "").sub(/\.md/, ".html") }
# end
require "rake-pipeline"
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@phillbaker
phillbaker / lmu.m
Created November 17, 2012 20:23
Macbook ambient light sensor data
// Compile with $ gcc -o lmutracker lmu.m -framework IOKit -framework CoreFoundation -framework Foundation
// Usage: ./lmu [now]
// Prints out the value from the ambient light sensor and the back light LED every 1/10 of a second. Optionally print just one value.
// Inspired by the code found at
// http://google-mac-qtz-patches.googlecode.com/svn-history/r5/trunk/AmbientLightSensor
// and http://osxbook.com/book/bonus/chapter10/light/
// and http://en.wikipedia.org/wiki/Wikipedia:Reference_desk/Archives/Computing/2010_February_10#Mac_OS_X_keyboard_backlight_drivers
// http://forums.macrumors.com/showthread.php?t=1133446
#include <stdio.h>