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
# 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
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
ricardo@local:~$ scp ~/.ssh/id_rsa.pub user@host:~/.ssh/authorized_keys
ricardo@local:~$ ssh user@host
user@host:~$ chmod 600 .ssh/authorized_keys
<?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}";
<?php
ini_set('default_charset', 'utf-8');
header('Content-type: application/xml');
$html = utf8_encode(file_get_contents("http://www.clicrbs.com.br/atlantidafm/jsp/default.jsp?uf=1&local=1&template=3343.dwt&pSection=726&section=12"));
// Tenho vergonha, mas foi o jeito para o lixo de HTML
preg_match_all(("/» &nbsp;Pretinho das (.*)<!-- Escutar--><!-- Baixar-->&nbsp;|&nbsp;<a/"), ($html), $matches);
$matches = explode("»", $matches[0][0]);
class Array
def shuffle!
size.downto(1) { |n| push delete_at(rand(n)) }
self
end
end
require 'rubygems'
require 'twibot'
<FilesMatch "\.(html|htm|js|css|gif|jpg|png)$">
FileETag None
<IfModule mod_headers.c>
Header unset ETag
Header unset Last-Modified
Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT"
Header set Cache-Control "public"
</IfModule>
</FilesMatch>
<IfModule mod_deflate.c>
@rduarte
rduarte / import_md5_bzip2.sh
Created April 7, 2009 18:38
Check MD5 integrity and import bzip2-sql files
#!/bin/bash
db_host="localhost"
db_name="database"
db_user="root"
db_pass=""
file_path="/full/path"
while read LINE; do
HASH=`echo $LINE | awk '{print $1}'`
FILE=`echo $LINE | awk '{print $2}'`
@rduarte
rduarte / codificador.php
Created April 2, 2009 22:40
algorithm based on base64 for general proposes
<?php
function codificar($valor, $chave){
if (($chave = codificacao_chave($chave)) !== false){
list($inicio, $fim) = $chave;
} else {
return false;
}
$base = base64_encode($valor);
$base = str_replace('=', '', $base);