Skip to content

Instantly share code, notes, and snippets.

@a740122
a740122 / gDNS.py
Last active August 29, 2015 14:14 — forked from gleicon/gDNS.py
# dns server using dnslib and gevent
# based on https://bitbucket.org/paulc/dnslib/src/80d85555aae4/src/server/gevent_server.py
# set the key as
# set IP:name ip_addr
# set TXT:name txtfield
# fallback on gevent's dns resolver
# gleicon 2011
import gevent
@a740122
a740122 / flash.sh
Last active August 29, 2015 14:15 — forked from fcicq/flash.sh
#!/bin/sh
#high chance need have a change ...
if [ ! $# -eq 2 ]; then
echo "usage: $0 UBOOTFILE MD5"
exit
fi
UBOOT_NAME=$1
MD5SUM_SHOULD_BE=$2

OpenWrt BarrierBreaker 14.07-rc3 手记

1 外置存储 - ExtRoot

1.1 USB HDD 分区

安装依赖和工具包:
# coding=utf-8
import datetime
import sys
import time
import threading
import traceback
import SocketServer
from dnslib import *
@a740122
a740122 / sslserver.py
Last active August 29, 2015 14:19 — forked from kryptek/sslserver.py
#install openssl
#sudo aptitude install python-openssl
from OpenSSL import SSL
import socket, SocketServer
class SSlSocketServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer):
def __init__(self, server_address, RequestHandlerClass, bind_and_activate=True):
SocketServer.BaseServer.__init__(self, server_address,
@a740122
a740122 / run.py
Last active August 29, 2015 14:28 — forked from Yukilas/run.py
[Django, Gevent, SocketIO] Run script to automatically restart Gunicorn when a change is made on a python file
#!/usr/bin/env python
# -*- coding:Utf-8 -*-
import os
import shlex
import subprocess
import sys
import time
from watchdog.events import FileSystemEventHandler
from watchdog.observers import Observer
@a740122
a740122 / gist:dffcfd83285e91822241
Created December 4, 2015 07:45 — forked from tmc/gist:777085
multiprocessing gevent chat example
import sys
import gevent
from gevent.monkey import patch_all; patch_all()
from gevent import server, event, socket
from multiprocessing import Process, current_process, cpu_count
"""
Simple multiprocess StreamServer that proxies messages between clients.
Avoids using a multiprocessing.Event since it blocks on a semaphore.
@a740122
a740122 / compile_stdlib.py
Created December 26, 2015 13:50 — forked from madebyjazz/compile_stdlib.py
Compile all Python scripts into single StdLib.dll .NET assembly
# Script below is based on following post:
# IronPython: EXE compiled using pyc.py cannot import module "os" - Stack Overflow
# http://stackoverflow.com/questions/6195781/ironpython-exe-compiled-using-pyc-py-cannot-import-module-os
import sys
sys.path.append('d:/projects/SomeProject/Libs/IronPython')
sys.path.append('d:/projects/SomeProject/Libs/IronPython/Lib')
sys.path.append('d:/projects/SomeProject/Libs/IronPython/Tools/Scripts')
import clr
@a740122
a740122 / python-selenium-open-tab.md
Created February 9, 2016 02:35 — forked from lrhache/python-selenium-open-tab.md
Python Selenium - Open new tab / focus tab / close tab

On a recent project, I ran into an issue with Python Selenium webdriver. There's no easy way to open a new tab, grab whatever you need and return to original window opener.

Here's a couple people who ran into the same complication:

So, after many minutes (read about an hour) of searching, I decided to do find a quick solution to this problem.

@a740122
a740122 / bluetooth.py
Created February 29, 2016 16:32 — forked from tito/bluetooth.py
Bluetooth example on Android using Python / Pyjnius
'''
Bluetooth/Pyjnius example
=========================
This was used to send some bytes to an arduino via bluetooth.
The app must have BLUETOOTH and BLUETOOTH_ADMIN permissions (well, i didn't
tested without BLUETOOTH_ADMIN, maybe it works.)
Connect your device to your phone, via the bluetooth menu. After the
pairing is done, you'll be able to use it in the app.