Skip to content

Instantly share code, notes, and snippets.

View rduarte's full-sized avatar
🏠
Working from home

Ricardo Duarte rduarte

🏠
Working from home
View GitHub Profile
@rduarte
rduarte / ubuntu-10.04-dev-server.sh
Created May 31, 2010 14:11
Install Ubuntu Lucid Lynx 10.04 development server with Apache2 + Ruby + Passenger + PHP5 + MySQL + SQLite3 + Imagemagick
# Update
apt-get update
apt-get dist-upgrade
# Install Apache + PHP5 + Ruby + Passenger
apt-get install libapache2-mod-passenger php5 passenger ssh build-essential apache2 apache2-mpm-prefork apache2-prefork-dev ruby1.8-dev irb libopenssl-ruby libreadline-ruby rdoc ri ruby ruby-dev
sudo a2enmod rewrite
# Install git
apt-get install git-core git-svn
# How to give your devise controllers all the same layout (e.g. "authentication" below)
class ApplicationController < ActionController::Base
layout :setup_layout
protected
def setup_layout
devise_controller? ? "authentication" : "application"
end
end
$(function () {
var toc = $("<ul>").css("margin-bottom", "20px !important");
$("div.main div.wikistyle h2").each(function() {
var id = $(this).text().replace(/\s+/g, "_").replace(/[^0-9a-zA-Z_.-]/g, "")
$(this).attr("id", id)
toc.append(
$("<li>").append($("<b>").append($("<a>").attr("href", "#" + id).text($(this).text())))
)
});
$("div.wikistyle").prepend(toc).prepend($("<h2>").text("Table of Contents"));
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
#!/bin/bash
##
# Deployment para Tomcat usando Git
##
# Configuração
WAR_DIR="/home/user/NetBeansProjects/project/dist"
WAR_FILE="project.war"
GIT_LOCAL="/home/user/git/project"
if [ "$1" = "root" ] ; then
Rails CMS alternatives
======================
Active projects:
---------------
adva-cms
repo: http://github.com/svenfuchs/adva_cms/
site: http://adva-cms.org/
Last update: 11/24/09
"the cutting edge Rails CMS platform"
@rduarte
rduarte / template.rb
Created November 12, 2009 23:22 — forked from elomar/template.rb
run 'gem sources -a http://gemcutter.org'
git :init
file '.gitignore', <<TXT
log/*.log
tmp/**/*
db/*.sqlite3
.DT_Store
TXT
@rduarte
rduarte / gist:232534
Created November 12, 2009 02:19 — forked from justintv/.bashrc
PS1="\\w:\$(git branch 2>/dev/null | grep '^*' | colrm 1 2)\$ "
@rduarte
rduarte / average_time_of_day.rb
Created October 9, 2009 00:00
RPCFN: Average Arrival Time For A Flight (#2)
require 'time'
def average_time_of_day(times)
clean = Array.new
times.each do |t|
parsed = Time.parse(t)
parsed += (60*60*24) if parsed < Time.now
clean.push(parsed)
end
clean[ (clean.count / 2.0).ceil - 1 ].strftime("%I:%M%p")
end
@rduarte
rduarte / gist:190009
Created September 21, 2009 01:15 — forked from anonymous/gist:44400
class ApplicationController < ActionController::Base
before_filter :set_application
private
def set_current_account
@current_account = Account.find_by_subdomain(request.subdomains.first)
end
end
class CustomersController < ApplicationController