Skip to content

Instantly share code, notes, and snippets.

@sousatg
sousatg / ahoy_api
Created January 3, 2016 02:49
API developed with Flask to retrive a list of proxy address and their connections.
from flask import Flask, jsonify
from lxml import etree
from urllib3 import PoolManager
import time
app = Flask(__name__)
def parseProxyString(proxyString):
keys = ["address", "port"]
values = proxyString.split(':')
from splinter import Browser
from lxml import etree
import json
# recebe um objecto etree e devolve uma string com codigo html
def get_page_posts(article):
article_text = article.xpath('.//div[contains(@class, "userContent")]')[0]
a = etree.tostring(article_text, pretty_print=True).encode('utf-8')
return a
from selenium import webdriver
url = 'http://betaalbare-website.be'
b = webdriver.Firefox()
b.get( url )
resolutions = [(1024, 768), (1920, 1080), (1366, 768), (1280, 800), (1024, 768), (800, 600)]
for largura, altura in resolutions:
output_name = 'ticked_' + str(largura) + 'x' + str(altura) + '.png'
@sousatg
sousatg / hilo.hs
Created February 12, 2016 17:58
The game of HILO coded in haskell
module Hilo where
import System.Random as R
jogo :: Int -> Int -> IO Int
jogo n x = do
putStr "Tentativa? "
str <- getLine
let y = read str
if y == x then
@sousatg
sousatg / TwitterBird,py
Created February 13, 2016 17:45
Twitter private API wrapper class
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import requests, time
from lxml import etree
class TwitterHammer:
def __init__(self, username, password):
self.username = username
self.password = password
@sousatg
sousatg / apostilando_scrapper.py
Last active February 14, 2016 11:56
Python scrapper to download ebooks from apostilando.com.br
#!/usr/bin/env/python
# -*- coding: utf-8 -*-
import requests
import uuid
import os
import csv
from lxml import etree
import time
@sousatg
sousatg / twitterfollowfollowers.py
Created February 14, 2016 12:19
Bot to follow followers of a twitter account
from splinter import Browser
import csv, time
class TwitterAccount:
def __init__(self, username, password):
self.username = username
self.password = password
self.b = Browser()
@sousatg
sousatg / hilo_game.py
Created March 27, 2016 13:05
Jogo HILO em Python
import random
n = int( random.random() * 100 )
tentativas = 0
while True:
a = raw_input('Numero entre 0 e 100: ')
if int(a) == n:
@sousatg
sousatg / phantomjs-facebook-update.js
Created March 29, 2016 12:59 — forked from ariefbayu/phantomjs-facebook-update.js
facebook status update using phantomjs
var page = new WebPage();
//spoof it as opera mini, to get the mobile page working properly
page.settings.userAgent = "Opera/9.80 (J2ME/MIDP; Opera Mini/6.5.26955/27.1407; U; en) Presto/2.8.119 Version/11.10";
function doLogin(){
page.evaluate(function(){
var frm = document.getElementById("login_form");
frm.elements["email"].value = "--enter-your-email--";
#!/usr/bin/python
# -*- coding: utf-8 -*-
class Reff:
def __init__(self, ent_id, subent_id, order_id, order_value):
self.ent_id = ent_id
self.subent_id = subent_id
self.order_id = '0000' + order_id
self.order_value = order_value
array = [3, 30, 9, 90, 27, 76, 81, 34, 49, 5, 50, 15, 53, 45, 62, 38, 89, 17, 73, 51]