Skip to content

Instantly share code, notes, and snippets.

@laanwj
laanwj / gcabi.c
Created November 15, 2017 07:47
Extract GCABI json
/**
arm-linux-gnueabihf-gcc -ggdb -g3 gcabi.c -o gcabi -I /.../galcore_headers/include_imx8_v6.2.3.129602
extract_structures_json.py gcabi _gcsHAL_INTERFACE _gcoCMDBUF _gcsQUEUE > data/gcs_hal_interface_GCABI.json
*/
#include <gc_abi.h>
struct _gcsHAL_INTERFACE x;
struct _gcoCMDBUF y;
struct _gcsQUEUE z;
@laanwj
laanwj / dumpcmdbufs.sh
Created August 25, 2017 12:54
a20x KGSL dump cmdbuf
#!/bin/bash
# enable command stream dumping, clear kernel ringbuffer,
# write output to a file provided on the command line
# this can be converted to .rd using dmesg2rd.py from
# https://github.com/laanwj/freedreno/blob/master/mlog/dmesg2rd.py
set -e
if [ "$(whoami)" != "root" ]; then
echo "This script needs to be executed as root"
exit 1
fi
@laanwj
laanwj / neontile.c
Created July 13, 2017 11:00
Vivante tiling experiments in NEON
/* Vivante tiling experiments in NEON
W.J. van der Laan 2017, MIT license
*/
/* gcc neontile.c -o neontile -O2 -mfpu=neon */
#define _POSIX_C_SOURCE 200112L
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
@laanwj
laanwj / stats.py
Created June 15, 2017 20:13
Count statistics about connections for bitcoind RPC
#!/usr/local/bin/python3 [5/1819]
import sys
sys.path.append('./bitcoin/test/functional')
from test_framework.authproxy import AuthServiceProxy, JSONRPCException
import time
import os
datadir = os.path.join(os.getenv('HOME'), '.bitcoin')
with open(os.path.join(datadir,'.cookie'),'r') as f:
cookie = f.read()
@laanwj
laanwj / do_backport.py
Created June 5, 2017 12:19
Script to do backports (pull ids listed in to_backport.txt or command line) in order of merge, to minimize number of conflicts.
#!/usr/bin/env python3
'''
Script to do backports (pull ids listed in to_backport.txt or command line) in order of merge,
to minimize number of conflicts.
'''
import git
import re
import shlex
import subprocess
import os, sys
@laanwj
laanwj / decrypt.py
Last active September 14, 2020 00:49
Decrypt router configuration
#!/usr/bin/env python3
# W.J. van der Laan 2017, distributed under MIT license
import binascii
import base64
import json
import os, sys
from Crypto import Random
from Crypto.Cipher import AES
KEY = binascii.a2b_hex(b'fffffbffeffffbfffbbfffbfdbfff7ffffffffffffffdfffff7fffffbfffffff')
@laanwj
laanwj / rpcfuncs.txt
Last active March 13, 2017 08:44
Bitcoin Core 0.14.x RPC functions with named arguments
abandontransaction(txid)
addmultisigaddress(nrequired, keys, account)
addnode(node, command)
addwitnessaddress(address)
backupwallet(destination)
bumpfee(txid, options)
clearbanned()
createmultisig(nrequired, keys)
createrawtransaction(transactions, outputs, locktime)
decoderawtransaction(hexstring)
@laanwj
laanwj / prompt-colors.sh
Created February 22, 2017 08:05
Generate debian/ubuntu prompt with random xterm256 colors
# Try colors for Ubuntu prompt
# . prompt_test.sh 123 125
if [ ! -z "$1" ] && [ ! -z "$2" ]; then
COLOR1=$1
COLOR2=$2
else
COLOR1=$((($RANDOM%240)+16))
COLOR2=$((($RANDOM%240)+16))
echo "Choosing random colors ${COLOR1} and ${COLOR2}"
fi
@laanwj
laanwj / fastcopy_chaindata.py
Last active April 23, 2018 13:45
Fast local copy of Bitcoin Core blockchain state
# This is now part of bitcoin-maintainer-tools:
# https://github.com/bitcoin-core/bitcoin-maintainer-tools/blob/master/fastcopy-chaindata.py
@laanwj
laanwj / gist:241c0462658a385c17a33c9dbf157a04
Created November 10, 2016 14:22
Transform feedback assembly vertex shader gc2000
0: 0085102e 00000800 40000020 00000000 0x2e.s32 t5.x___, ?4?0.xxxx, void, void
1: 0105102e 15400800 40000020 00000000 0x2e.s32 t5._y__, ?4?0.yyyy, void, void
2: 0205102e 2a800800 40000020 00000000 0x2e.s32 t5.__z_, ?4?0.zzzz, void, void
3: 0405102e 3fc00800 40000020 00000000 0x2e.s32 t5.___w, ?4?0.wwww, void, void
4: 07861009 00000000 00000000 00390058 mov t6, void, void, t5
5: 00861001 00006800 40000000 20000028 add.s32 t6.x___, t6.xxxx, void, u2.xxxx
6: 00851001 00000800 00000000 20400008 add t5.x___, t0.xxxx, void, -u0.xxxx
7: 00000056 00005800 01fe0140 00001502 branch.gt void, t5.xxxx, u2.wwww, 42
8: 0085102d 00006800 40000000 00000000 i2f.s32 t5.x___, t6.xxxx, void, void
9: 01051003 00005800 000001c0 00000002 mul t5._y__, t5.xxxx, u3.xxxx, void