Skip to content

Instantly share code, notes, and snippets.

View tejo's full-sized avatar

Matteo Parmi tejo

View GitHub Profile
package main
import (
"fmt"
"log"
"net/http"
"runtime"
"time"
)
@staltz
staltz / introrx.md
Last active July 29, 2024 05:55
The introduction to Reactive Programming you've been missing
@Marchino
Marchino / controller.rb
Created November 29, 2011 09:00
indexing config
class Controller < ApplicationController
@items = Sunspot.search(ModelName) do
fulltext params[:q], :fields => ["description_#{I18n.locale}".to_sym, :author]
end
end
class ApplicationController < ActionController::Base
before_filter :page_params, :only => :index
def page_key
(self.class.to_s + "_page").to_sym
end
def page_params
if params[:page] then
session[page_key] = params[:page]
@dnagir
dnagir / rspec-syntax-cheat-sheet.rb
Created November 5, 2010 09:29
RSpec 2 syntax cheat sheet by example
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
@pixeltrix
pixeltrix / routes.rb
Created October 29, 2010 13:21
Examples of advanced Rails 3.0 routes
Rails.application.routes.draw do
get '/(:locale)/products/(:category)/(page/:page).:extension',
:to => 'products#index',
:as => :products,
:constraints => {
:locale => /[a-z]{2}/,
:category => /.+?/,
:page => /\d+/
},