Skip to content

Instantly share code, notes, and snippets.

@ii0
ii0 / http_echo_and_proxy_server.py
Created August 21, 2018 09:20 — forked from pomack/http_echo_and_proxy_server.py
A simple python HTTP server that either serves as a proxy or as an echo server. If working as an echo server, it outputs the headers and body into log output and to the client, which is useful when debugging a reverse proxy or caching server to see what is being sent. If working as a proxy server, it outputs what the request headers will be to t…
#!/usr/bin/env python
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
import StringIO
import argparse
import logging
import os
import random
import sys
import urllib2
@ii0
ii0 / aacs.py
Created August 20, 2018 05:05 — forked from fffonion/aacs.py
Anti-anti-crawler scripts
import re
import time
mkcookie = lambda coo: ";".join(["%s=%s" % (k,v) for k,v in coo.iteritems()])
def autodetect(resp, ct, ht, cookie, headers, url):
__func = None
while 'set-cookie' in resp:
coostr = resp['set-cookie']
_session = re.findall('yunsuo_session_verify=(\w+)', coostr)
@ii0
ii0 / tornadorequesthandler.py
Created July 24, 2018 05:18 — forked from cjgiridhar/tornadorequesthandler.py
Tornado - POST Request Handler
import tornado.ioloop
import tornado.web
class Hello(tornado.web.RequestHandler):
def get(self):
self.write("Hello, world")
class User(tornado.web.RequestHandler):
def get(self):
@ii0
ii0 / Python3.5-Build.txt
Created June 21, 2018 06:43 — forked from nesffer/Python3.5-Build.txt
Python 3.5 Build on Ubuntu 14.04.3
Python build finished successfully!
The necessary bits to build these optional modules were not found:
_bz2 _curses _curses_panel
_dbm _gdbm _lzma
_sqlite3 _ssl _tkinter
readline zlib
To find the necessary bits, look in setup.py in detect_modules() for the module's name.
sudo apt-get install libbz2-dev libncurses5-dev libgdbm-dev liblzma-dev sqlite3 libsqlite3-dev openssl libssl-dev tcl8.6-dev tk8.6-dev libreadline-dev zlib1g-dev
@ii0
ii0 / Python3.6-build-on-CentOS7.txt
Created June 13, 2018 09:10 — forked from tao12345666333/Python3.6-build-on-CentOS7.txt
Python3.6 source code build on CentOS 7.3
Python build finished successfully!
The necessary bits to build these optional modules were not found:
_dbm _gdbm _lzma
_sqlite3 _tkinter readline
To find the necessary bits, look in setup.py in detect_modules() for the module's name.
so.
sudo yum install gdbm-devel tk-devel xz-devel sqlite-devel readline-devel bzip2-devel ncurses-devel zlib=devel
@ii0
ii0 / Description.md
Created June 8, 2018 05:56 — forked from juanje/Description.md
Limit Chrome from eating all the memory and CPU

I was tired of Chrome eating all my laptop resources so I decided to put some limit to it with cgroup.

As I was using Ubuntu 12.04 with support for cgroup, I installed the package cgroup-bin and add the following group to the file /etc/cgconfig.conf:

group browsers {
    cpu {
#       Set the relative share of CPU resources equal to 25%
        cpu.shares = "256";
 }
@ii0
ii0 / httpserve.py
Created April 24, 2018 02:50 — forked from ThomasChiroux/httpserve.py
python2 and python3 compliant simple http server
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""launch small http server
"""
import sys
try:
from SimpleHTTPServer import SimpleHTTPRequestHandler
except ImportError:
@ii0
ii0 / tetris.py
Created April 19, 2018 05:52 — forked from silvasur/tetris.py
Tetris implementation in Python
#!/usr/bin/env python2
#-*- coding: utf-8 -*-
# NOTE FOR WINDOWS USERS:
# You can download a "exefied" version of this game at:
# http://hi-im.laria.me/progs/tetris_py_exefied.zip
# If a DLL is missing or something like this, write an E-Mail ([email protected])
# or leave a comment on this gist.
# Very simple tetris implementation
@ii0
ii0 / auto.py
Created February 12, 2018 03:07 — forked from iann0036/auto.py
Python Input Record and Play
import pyautogui, time, sys, os, win32api, win32gui, win32con, datetime, pyHook, pythoncom
from optparse import OptionParser
'''
Python Automated Actions Script by Ian Mckay
Version 0.1 - 20151217
'''
pyautogui.PAUSE = 0
pyautogui.FAILSAFE = True
@ii0
ii0 / 1) Install
Created August 16, 2017 05:10 — forked from nghuuphuoc/1) Install
Install Redis on Centos 6
// --- Compiling ---
$ wget http://download.redis.io/releases/redis-2.8.3.tar.gz
$ tar xzvf redis-2.8.3.tar.gz
$ cd redis-2.8.3
$ make
$ make install
// --- or using yum ---
$ rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
$ rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm