Skip to content

Instantly share code, notes, and snippets.

View habedi's full-sized avatar
🚀

Hassan Abedi habedi

🚀
View GitHub Profile
@habedi
habedi / pprcd.py
Last active August 29, 2015 14:16 — forked from dgleich/pprcd.py
import collections
import sys
# setup the graph
G = {
1:set([ 2, 3, 5, 6,]),
2:set([ 1, 4,]),
3:set([ 1, 6, 7,]),
4:set([ 2, 5, 7, 8,]),
5:set([ 1, 4, 6, 8, 9, 10,]),
@habedi
habedi / pingpong.erl
Last active August 29, 2015 14:21 — forked from torgeir/pingpong.erl
% networked ping
% --
% Open firewall ports 4369 (erlang port mapper) and 9100-9105 (communication ports)
%
% On node 1 start your shell with this command:
% erl -name node@hostname1.com -setcookie cook -kernel inet_dist_listen_min 9100 inet_dist_listen_max 9105
%
% On node 2 start your shell with this command:
% erl -name node@hostname2.com -setcookie cook -kernel inet_dist_listen_min 9100 inet_dist_listen_max 9105
%
#!/usr/bin/env python
import socket
import threading
import select
import sys
terminateAll = False
class ClientThread(threading.Thread):
#!/usr/bin/env python
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
"""
@habedi
habedi / client.py
Last active August 29, 2015 14:22 — forked from micktwomey/client.py
import socket
if __name__ == "__main__":
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(("localhost", 9000))
data = "some data"
sock.sendall(data)
result = sock.recv(1024)
print result
sock.close()
from grab import Grab, GrabError
from multiprocessing.dummy import Pool as ThreadPool
import time
def load_proxy_list(filepath):
f = open(filepath)
proxy_list = f.read().splitlines()
f.close()
return proxy_list
# If /json route receives header "application/json"
@app.route("/json", methods=['GET','POST'])
def json():
app.logger.debug("JSON received...")
app.logger.debug(request.json)
if request.json:
mydata = request.json # will be
#!flask/bin/python
from flask import Flask, jsonify, abort, request, make_response, url_for
from flask.ext.httpauth import HTTPBasicAuth
app = Flask(__name__, static_url_path = "")
auth = HTTPBasicAuth()
@auth.get_password
def get_password(username):
if username == 'miguel':
@habedi
habedi / auth-basic.conf
Last active August 29, 2015 14:27 — forked from Thermionix/auth-basic.conf
nginx reverse proxy for sickbeard, couchpotato etc.
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/htpasswd;
@habedi
habedi / server.py
Last active September 10, 2015 09:02 — forked from fmoo/server.py
CONNECT-enabled HTTP Proxy Server
from twisted.web.proxy import Proxy, ProxyRequest
from twisted.internet.protocol import Protocol, ClientFactory
import urlparse
from twisted.python import log
class ConnectProxyRequest(ProxyRequest):
"""HTTP ProxyRequest handler (factory) that supports CONNECT"""
connectedProtocol = None