Skip to content

Instantly share code, notes, and snippets.

View gabrielfalcao's full-sized avatar

Gabriel Falcão gabrielfalcao

View GitHub Profile
@gabrielfalcao
gabrielfalcao / php.rb
Created December 15, 2010 01:43
PHP formula for Homebrew
require 'formula'
class Php <Formula
url 'http://www.php.net/get/php-5.3.4.tar.bz2/from/br2.php.net/mirror'
homepage 'http://php.net'
version '5.3.4'
md5 '2c069d8f690933e3bf6a8741ed818150'
depends_on 'jpeg'
depends_on 'libpng'
String.prototype.escapeToRegex = function (){
var parts = [];
for (x=0;x<this.length;x++){parts.push("["+this[x]+"]");}
return parts.join("");
}
String.prototype.escapeToRegexNegative = function (){
var last = "", parts = [];
for (x=0;x<this.length;x++){
parts.push(last.escapeToRegex() + "[^"+this[x]+"]");
last += this[x];
@gabrielfalcao
gabrielfalcao / selenium_webdriver_browser.py
Created January 29, 2011 03:15
nice stuff, such as drag and drop for selenium2's webdriver
class SeleniumBrowser(object):
def __init__(self):
self.driver = WebDriver()
def _extract_error(self, exception):
regex = re.compile(ur'URL = (?P<url>\S+) Response_Code = (?P<status>\d+) Error_Message = (?P<message>.*)')
found = regex.search(unicode(exception))
if found:
return found.groupdict()
@gabrielfalcao
gabrielfalcao / .bash_profile
Created March 1, 2011 04:49
badass bash profile
# -*- coding: utf-8 -*-
# <bash_profile - for mac>
# Copyright (C) <2011> Gabriel Falcão <[email protected]>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
/*var now = new Date();
var horas = now.getHours()
var minutos = now.getMinutes()
var agora = horas+":"+minutos;
*/
$("div.programa span.hora:visible:contains('07:21')").parents("div.programa").find("span.abrir").click()
@gabrielfalcao
gabrielfalcao / __init__.py
Created March 25, 2011 22:22
hacked lockfile
"""
lockfile.py - Platform-independent advisory file locks.
Requires Python 2.5 unless you apply 2.4.diff
Locking is done on a per-thread basis instead of a per-process basis.
Usage:
>>> lock = LockFile('somefile')
>>> try:
@gabrielfalcao
gabrielfalcao / markdown2mediawiki.py
Created April 6, 2011 19:33
small tornado server that translate a few parts of markdown syntax to mediawiki, not 100% functional but helps a lot
# #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (C) <2011> Gabriel Falcão <[email protected]>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
@gabrielfalcao
gabrielfalcao / turn-css-file-links-into-locals.py
Created May 5, 2011 18:16
This snippet parses a css file thru csstyle module, finds the external links, download them, save locally, fixes the css file to point to new paths and also prettifies the css
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import time
import urlparse
from lettuce import before, after, world
from splinter.browser import Browser
from django.conf import settings
#!/bin/bash
# This hook is run after every virtualenv is activated.
get_path_for() {
echo $HOME/$1/`echo $VIRTUAL_ENV | sed 's,.*/,,g'`
}
destination_path=`get_path_for Projetos`
if [ -e $destination_path ]; then
pushd $destination_path;
fi;