Skip to content

Instantly share code, notes, and snippets.

View tejo's full-sized avatar

Matteo Parmi tejo

View GitHub Profile
@tejo
tejo / rbenv-install-system-wide.sh
Created October 14, 2011 21:03
rbenv install and system wide install on Ubuntu 10.04 LTS.
# Update, upgrade and install development tools:
apt-get update
apt-get -y upgrade
apt-get -y install build-essential
apt-get -y install git-core
# Extras for RubyGems and Rails:
apt-get -y install zlib1g-dev
apt-get -y install libssl-dev libsqlite3-dev
apt-get -y install libreadline5-dev
@tejo
tejo / gist:1281393
Created October 12, 2011 14:41
instant webserver
require 'webrick'
require 'webrick/accesslog'
include WEBrick
require 'thread'
require 'pp'
root_dir = "./"
http_dir = File.expand_path(root_dir)
require 'rubygems'
require 'spork'
Spork.prefork do
# Loading more in this block will cause your tests to run faster. However,
# if you change any configuration or code from libraries loaded here, you'll
# need to restart spork for it take effect.
# This file is copied to spec/ when you run 'rails generate rspec:install'
127.0.0.1 hl2rcv.adobe.com
127.0.0.1 t3dns.adobe.com
127.0.0.1 3dns-1.adobe.com
127.0.0.1 3dns-2.adobe.com
127.0.0.1 3dns-3.adobe.com
127.0.0.1 3dns-4.adobe.com
127.0.0.1 activate.adobe.com
127.0.0.1 activate-sea.adobe.com
127.0.0.1 activate-sjc0.adobe.com
127.0.0.1 activate.wip.adobe.com
@tejo
tejo / vim.rb
Created June 8, 2011 15:24
vim formula with ruby support for brew
require 'formula'
class Vim <Formula
url 'ftp://ftp.vim.org/pub/vim/unix/vim-7.3.tar.bz2'
homepage 'http://www.vim.org/'
md5 '5b9510a17074e2b37d8bb38ae09edbf2'
version '7.3.135'
def patchlevel; 135 end
def features; %w(tiny small normal big huge) end
@tejo
tejo / gist:1012534
Created June 7, 2011 15:52
mechanize example with login and saved cookie
require 'rubygems'
require 'mechanize'
require 'mysql'
agent = Mechanize.new { |agent|
agent.user_agent_alias = 'Mac Safari'
}
@tejo
tejo / gist:1012496
Created June 7, 2011 15:32
2011 rails template
comandi setup:
rails g cucumber:install --capybara
rails g rspec:install
rails g devise:install
rails g jquery:install
rails generate devise user
@tejo
tejo / 0_instructions.txt
Created June 3, 2011 08:57 — forked from sgruhier/0_instructions.txt
backport asset pileline rails 3.0.x
Some brief instructions on how to use Sprocket 2 in Rails to get CoffeeScript
powered JS and SASS powered CSS with YUI compression all via the magic of rack.
This stuff will be native in Rails 3.1 and the layout of the files on the
filesystem will be different but this guide will get you working with it
while we wait for all that to finalize.
Ignore the number prefixes on each file. This is just to ensure proper order in the Gist.
It's based on eric1234 gist https://gist.github.com/911003. ijust made it 3.1 compliant in terms of convention
@tejo
tejo / gist:973089
Created May 15, 2011 12:06
business day between 2 date
(((calculate_working_days(20.days.ago ,Time.now, [0,6])/60)/60)/24).to_i
# wdays is an array with the days of the week
# to exclude (eg: [0,6] for sunday and saturday )
def calculate_working_days(d1,d2,wdays)
diff = d2 - d1
holidays = 0
ret = (d2-d1).divmod(7)
@tejo
tejo / carousel.js
Created April 18, 2011 07:40 — forked from paolochiodi/carousel.js
advanced js by paolo chiodi