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
<?php
$useCache = true;
if ($useCache){
if (isset($_SERVER['REQUEST_URI']) && $_SERVER['REQUEST_URI']!="/"){
$cacheName=str_replace('/','-',$_SERVER['REQUEST_URI']);
$cacheName = substr($cacheName,1);
}else{
$cacheName='site-index.html';
}
$cacheFile = "cache/{$cacheName}";
ricardo@local:~$ scp ~/.ssh/id_rsa.pub user@host:~/.ssh/authorized_keys
ricardo@local:~$ ssh user@host
user@host:~$ chmod 600 .ssh/authorized_keys
set :application, "myapp"
set :keep_releases, 5
# git options
set :scm, "git"
set :repository, "git://github.com/georgeguimaraes/myapp.git"
set :branch, "master"
set :deploy_via, :remote_cache
# deploy credentials
# Removendo porcarias
run "rm README"
run "rm public/index.html"
run "rm public/favicon.ico"
run "rm public/robots.txt"
# Git
git :init
file(".gitignore") do
<<-EOF
@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
@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:232534
Created November 12, 2009 02:19 — forked from justintv/.bashrc
PS1="\\w:\$(git branch 2>/dev/null | grep '^*' | colrm 1 2)\$ "
@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
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"