This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding=utf-8 | |
import datetime | |
import sys | |
import time | |
import threading | |
import traceback | |
import SocketServer | |
from dnslib import * | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
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:
- http://stackoverflow.com/questions/17547473/how-to-open-a-new-tab-using-selenium-webdriver
- http://stackoverflow.com/questions/6421988/webdriver-open-new-tab/9122450#9122450
- https://groups.google.com/forum/#!topic/selenium-users/kah4iEPRopc
- ... and many many more.
So, after many minutes (read about an hour) of searching, I decided to do find a quick solution to this problem.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
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. |
OlderNewer