Skip to content

Instantly share code, notes, and snippets.

View brutuscat's full-sized avatar

Mauro Asprea brutuscat

View GitHub Profile
@brutuscat
brutuscat / index.json.haml
Created February 14, 2012 09:59
Rails HAML Json render
:plain
[
- @movies.each do |movie|
:plain
{
"name":"#{movie.name}",
"description":"#{j(movie.description)}"
},
]
@brutuscat
brutuscat / gist:1270928
Created October 7, 2011 17:55
A bash for loop to rename all files with an extension, recursively.
# Replace the first ".less" with your extension and ".css.less" with the desired one
for i in `find . -type f`; do mv "$i" `basename -s .less "$i"`.css.less ; done
@brutuscat
brutuscat / bsas_neighborhoods.rb
Created October 7, 2011 13:40
Buenos Aires's neighborhoods (Barrios de Buenos Aires y Localidades de la Provincia)
# Neighborhoods from the Autonomous Capital City official ones and some not so.
TOWNS_CABA = Set.new ["Agronomía","Almagro","Balvanera","Barracas","Belgrano",
"Boedo","Caballito","Chacarita","Coghlan","Colegiales","Constitución","Flores",
"Floresta","La Boca","La Paternal","Liniers","Mataderos","Monserrat",
"Monte Castro","Nueva Pompeya","Núñez","Palermo,","Parque Avellaneda",
"Parque Chacabuco","Parque Chas","Parque Patricios","Puerto Madero","Recoleta",
"Retiro","Saavedra","San Cristóbal","San Nicolás","San Telmo","Vélez Sársfield",
"Versalles","Villa Crespo","Villa del Parque","Villa Devoto","Villa Gral. Mitre",
"Villa Lugano","Villa Luro","Villa Ortúzar","Villa Pueyrredón","Villa Real",
"Villa Riachuelo","Villa Santa Rita","Villa Soldati","Villa Urquiza","Abasto",
@brutuscat
brutuscat / wget.limited.scapper
Created October 4, 2011 09:09
wget command to scrap just a portion of a website's HTML
# This way you can test your scripts in your localhost. It's like using the
# --mirror option without downloading all the needed resources, just the HTML.
# Add "-e robots=off" to be evil
# Add --continue so wget won't download already downloaded files
wget -r -N -E --convert-links --random-wait -l 3 --wait=2 --user-agent=" Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:6.0.1) Gecko/20100101 Firefox/6.0.12011-09-09 13:03:08" "URL-WEBSITE?and=1&params=2"
@brutuscat
brutuscat / application.rb
Created September 22, 2011 17:39
Fix issue with Ruby1.9.2, Rails and Psych (new YAML parser)
# Downgrade to use old YAML parser
YAML::ENGINE.yamler = "syck"
# Lots of other stuff .....
@brutuscat
brutuscat / ExceptionThrower.php
Created February 17, 2011 09:38
Utility for catching PHP errors, warnings and notices, then converting them (throwing) to an exception that can be caught at runtime @author Jason Hinkle - http://verysimple.com/2010/11/02/catching-php-errors-warnings-and-notices/ @copyright 1997-20
<?php
/**
* Utility for catching PHP errors and converting them to an exception
* that can be caught at runtime
* @author Jason Hinkle
* @copyright 1997-2011 VerySimple, Inc.
* @license http://www.gnu.org/licenses/lgpl.html LGPL
* @version 1.0
*/
class ExceptionThrower