Skip to content

Instantly share code, notes, and snippets.

@jonte
jonte / tmp105.md
Last active Jun 25, 2021
Emulating a tmp105 temperature sensor using QEMU and Linux
View tmp105.md

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
@nerdolo
nerdolo / quadrangle to triangles
Created Apr 20, 2020
function for dividing quadrangle into two triangles that create it regardless of initial points order
View quadrangle to triangles
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
@coderjo
coderjo / attach_cow_image.sh
Last active Jul 3, 2021
access a disk image read-only with a copy-on-write overlay to allow fsck or the like to write changes
View attach_cow_image.sh
#!/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"
@robertpitt
robertpitt / socks5.js
Created Jul 30, 2012
SOCKS5 Server as per rfc1928 (nodejs)
View socks5.js
/**
* 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 Aug 18, 2018
ed2kHash class for python (you may use it as alcc)
View ed2kHash.py
# 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