Skip to content

Instantly share code, notes, and snippets.

@robertpitt
robertpitt / socks5.js
Created July 30, 2012 01:30
SOCKS5 Server as per rfc1928 (nodejs)
/**
* SOCKS5 Proxy as per RFC1928
* @see : http://www.ietf.org/rfc/rfc1928.txt
*/
/**
* Load Dependancies
*/
var net = require('net'),
@fcicq
fcicq / ed2kHash.py
Last active August 18, 2018 11:54
ed2kHash class for python (you may use it as alcc)
# by fcicq (fcicq at fcicq dot net) @ 2012.5.12, Released under GPLv2
import hashlib
try:
from cStringIO import StringIO
except ImportError:
from io import BytesIO as StringIO
if bytes != str: ord = int
class ed2kHash():
CHUNK_SIZE = 9728000
BLOCK_SIZE = 262144
@nerdolo
nerdolo / quadrangle to triangles
Created April 20, 2020 19:46
function for dividing quadrangle into two triangles that create it regardless of initial points order
import math
def matrix_det(mat): # mat - matrix
det, k_1, k_2 = 0, 1, 1
for i in range(3):
for j in range(3):
k_1 *= mat[(i + j) % 3][j % 3]
k_2 *= mat[-((i + j) % 3)][-(j % 3)]
det += k_1 - k_2
return det
@jonte
jonte / tmp105.md
Last active September 29, 2024 07:12
Emulating a tmp105 temperature sensor using QEMU and Linux

This will configure QEMU to expose a tmp105 temperature sensor on the i2c-0 bus on x86_64. The temterature sensor can have its temperature set from the host OS, and the temperature can be read from the Linux client OS using the lm75 kernel module.

Building QEMU

For convenience, we will be emulating an x86 system. The x86 configuations which QEMU ships with do not contain the tmp105 sensor we will be using, so first we need to enable it.

Assuming you have the qemu sources in the qemu directory:

# cd qemu

echo "CONFIG_TMP105=y" >> default-configs/i386-softmmu.mak

@coderjo
coderjo / attach_cow_image.sh
Last active October 29, 2024 19:15
access a disk image read-only with a copy-on-write overlay to allow fsck or the like to write changes
#!/bin/bash
# usage: attach_cow_image.sh [imagefile] [cowfile] [devname]
# imagefile: path to the image file you want to load
# cowfile: path to the file to store writes into. If it doesn't exist, a sparse 1GB file will be created.
# devname: the name you want the drive to show up as in /dev/mapper
imgfile="$1"
cowfile="$2"
dmname="$3"