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
# Verifies certificates when connecting using HTTPS. | |
# Needs cacert.txt (cat /usr/share/ca-certificates/mozilla/* > cacert.txt). | |
import http.client | |
import socket | |
import ssl | |
class VerifiedHTTPSConnection(http.client.HTTPSConnection): | |
def connect(self): | |
sock = socket.create_connection((self.host, self.port), self.timeout) | |
if self._tunnel_host: |
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
# Make LOC history of a git repo and display pretty graph. | |
# | |
# Usage: | |
# cd ~/myrepo | |
# python linum.py ~/mylinecountingscript.sh | |
# | |
# Counting script should count LOC in current directory. Example: | |
# wc --lines $(find -name '*.py') | |
# | |
# Requires Python Matplotlib. |
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 | |
import sensors | |
import subprocess | |
import time | |
def emergency(): | |
subprocess.check_call(['sudo', 'pm-suspend']) | |
def watch(): | |
while True: |
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
from __future__ import division | |
from math import sin | |
import math | |
import sys | |
import wave | |
import struct | |
import subprocess | |
import os | |
RATE = 44000 | |
snd_i = 0 |
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 pipes | |
import shlex | |
def shellquote(s): | |
return pipes.quote(s) if s else "''" | |
def reext(thing, src, dst): | |
if isinstance(thing, list): | |
return map(lambda a: reext(a, src, dst), thing) |
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 getpass, hashlib | |
domain = raw_input('domain: ') | |
assert not domain.startswith('www.') | |
pas = getpass.getpass() | |
pas1 = getpass.getpass() | |
assert pas == pas1 | |
print hashlib.sha1(domain + pas).hexdigest()[:16] |
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
type | |
TThing = object | |
a: int | |
PThing = ref TThing | |
proc destruct1(instance: var TThing) {.destructor.} = | |
echo "destory TThing number ", instance.a | |
block: | |
var a: TThing = TThing(a: 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
# Usage: ifconfig | python ifco.py | |
import sys | |
import socket | |
readline = sys.stdin.readline | |
def ip2num(a): | |
return int(socket.inet_aton(a).encode('hex'), 16) | |
def num2ip(i): | |
return socket.inet_ntoa(hex(i)[2:].decode('hex')) |
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 struct | |
import sys | |
import gzip | |
fn = sys.argv[1] | |
f = open(fn) | |
if f.read(8) != 'ANDROID!': | |
sys.exit('Not a mkbootimg file.') | |
_header = struct.unpack('<' + 'I' * 10, f.read(10 * 4)) |
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 pygame | |
import argparse | |
import time | |
parser = argparse.ArgumentParser(description='Display raw image (typically a framebuffer).') | |
parser.add_argument('file') | |
parser.add_argument('width', type=int) | |
parser.add_argument('height', type=int) | |
parser.add_argument('--format', default='RGBX') |
OlderNewer