Skip to content

Instantly share code, notes, and snippets.

View thulio's full-sized avatar

Thúlio Costa thulio

View GitHub Profile
@thulio
thulio / zombiefox.py
Last active December 20, 2015 09:29
Processo zumbi do Firefox/PhantomJS
#!/usr/bin/env ipython
import splinter
import subprocess
b = splinter.browser.Browser()
subprocess.Popen(["pkill", "-f", "ipython"])
@thulio
thulio / splinter_reject.py
Created June 24, 2013 20:04
Splinter user-agent getting rejected
import requests
url = "http://guitarshop.com.br/prod,idloja,5372,idproduto,3575917,cordas-amp-guitarra-g5--15w-c--drive"
headers = {"User-Agent": "python/urllib"}
r = requests.get(url, headers=headers)
print(r.status_code)
headers = {"User-Agent": "python/splinter"}
r = requests.get(url, headers=headers)
print(r.status_code)
headers = {"User-Agent": "splinter"}
r = requests.get(url, headers=headers)
@thulio
thulio / mocktrue.py
Created August 7, 2012 03:05 — forked from daltonmatos/mocktrue.py
Hack to mock the python True object
class True(object):
def __init__(self, iterations=1):
self.iterations = iterations
self.current_iteration = 0
def __nonzero__(self):
if self.current_iteration < self.iterations:
self.current_iteration += 1
return 1
@thulio
thulio / gcccpuopt.sh
Created July 24, 2012 12:21
Get GCC optimal compile flags
#!/bin/sh
# Print the gcc cpu specific options tailored for the current CPU
# Author:
# http://www.pixelbeat.org/
# Notes:
# This script currently supports Linux,FreeBSD,Cygwin
# This script is x86 (32 bit) specific
# It should work on any gcc >= 2.95 at least
@thulio
thulio / pip_update_all.sh
Created August 11, 2011 16:51
Update all python packages installed with pip
pip freeze -l | cut -d'=' -f 1 | xargs pip install -U