Skip to content

Instantly share code, notes, and snippets.

View laanwj's full-sized avatar

Mara van der Laan laanwj

View GitHub Profile
@laanwj
laanwj / moonphase.py
Last active September 15, 2022 14:46
#!/usr/bin/python3
import datetime
import bisect
import ephem
DAY = 1.0/29.33
MOONPHASE = [
(0.0/4.0 + DAY, '🌑', 'New moon'),
(1.0/4.0 - DAY, '🌒', 'Waxing crescent moon'),
(1.0/4.0 + DAY, '🌓', 'First quarter moon'),
From b12050e430f6bf37334dd7b6995dd8c97d8aa68a Mon Sep 17 00:00:00 2001
From: "Wladimir J. van der Laan" <[email protected]>
Date: Thu, 13 Jul 2017 15:43:09 +0000
Subject: [PATCH] etnaviv: NEON implementations of tiling/untiling
Experiemental NEON implementation of tiling/untiling that adds
specialized NEON function for tiling 8, 16, 32 bit per element
4x4 tiles. To optimize memory read/write sizes, there are functions that
process multiple horizontically adjactent tiles as well. These
are automatically used for the part that consists of whole tiles.
#!/usr/bin/python3
import json
class notreallydict(dict):
def __init__(self, x):
dict.__init__(self, x)
self.x = x
def items(self):
return self.x
@laanwj
laanwj / fds.c
Created November 30, 2017 20:28
Check fd assignment
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
int main()
{
close(STDIN_FILENO);
int fd = open("/dev/null", O_RDWR);
@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 January 27, 2025 09:10
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')