Skip to content

Instantly share code, notes, and snippets.

View jonte's full-sized avatar

Jonatan Pålsson jonte

View GitHub Profile
><fs> cryptsetup_open /dev/sda encrypted readonly:false crypttype:luks cipher:aes-cbc-plain
Enter key or passphrase ("key"):
guestfsd: => cryptsetup_open (0x1fc) took 0.02 secs
guestfsd: <= cryptsetup_open (0x1fc) request length 104 bytes
commandrvf: stdout=n stderr=y flags=0x0
commandrvf: udevadm --debug settle -E /dev/sda
SELinux enabled state cached to: disabled
No filesystem is currently mounted on /sys/fs/cgroup.
Failed to determine unit we run in, ignoring: No data available
jonte /
Last active May 16, 2024 23:03
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

GVariant *v = g_variant_dict_end(priv->prop_changed_dict);
GVariantBuilder *vb = g_variant_builder_new(g_variant_type_new("(sa{sv}as)"));
g_variant_builder_add(vb, "s", "Hello world");
g_variant_builder_add(vb, "a{sv}", v);
g_variant_builder_add(vb, "s", NULL);
jonte /
Last active August 29, 2015 14:27
ELFA Shopping list for the "Make: Electronics" book
jonte / Instructions
Created December 16, 2013 11:53
Instructions for getting backlight working on UX301LAA ultrabook
Core problem:
Fn buttons are controlled via ACPI. ACPI is configured via a board specific firmware called the DSDT. The DSDT sections for backlight broken for UX301LAA, so it needs fixing. I have attached my DSDT file which work on my machine (I have not tested it extensively, but backlight works at least).
#1 Dump the current DSDT to a file:
cat /sys/firmware/acpi/tables/DSDT > dsdt
#2 The DSDT is compiled, so we need to decompile it
iadsl -d dsdt
#3 Often, the file is not properly decompiled, so re-compile it in order to discover any de-compilation errors. Fix any errors (the code is probably unparsable if there are errors, so you need to guess the correct semantics).
jonte /
Created January 20, 2013 10:43
Hack to parse FAT32
import struct
import sys
def getBytes(fs, pos, numBytes):
byte =
if (numBytes == 2):
formatString = "H"
elif (numBytes == 1):
formatString = "B"
jonte / gist:972206
Created May 14, 2011 13:26
LLVM register error
; The error:
; llvm-as: core012.ll:84:1: error: instruction expected to be numbered '%4'
; %3 = getelementptr [6 x i8]* @.const1, i32 0, i64 0
; ^
define void @printBool(i1 %par.b) {
#include <stdio.h>
#include <stdlib.h>
int main(){
FILE *fpipe;
char *command="echo \"2+2.\" | erl_call -sname ggs -e";
char line[256];
if ( !(fpipe = (FILE*)popen(command,"r")) ){
perror("Problems with the pipe");
jonte / v8test.erl
Created January 27, 2011 00:54
run() ->
{ok, VM} = erlv8_vm:start(),
Global = erlv8_vm:global(VM),
Global:set_value("callback", erlv8_object:new([{"exec", fun (#erlv8_fun_invocation{}, []) -> myCallback() end}])),
jonte / js_runner.erl
Created January 25, 2011 15:54
-export([executeJS/2, boot/0]).
boot() ->
{ok, Port} = js_driver:new(),
executeJS(Port, Data) ->
ok = js:define(Port, <<"function helloworld(name){return 'Hello, ' + name}">>),