Skip to content

Instantly share code, notes, and snippets.

View dbnicholson's full-sized avatar

Dan Nicholson dbnicholson

View GitHub Profile
#!/usr/bin/env python3
import os
from shutil import rmtree
from subprocess import run
from timeit import repeat
CHANNEL_ID = 'f393c30f95fb4bec87f873b2013ec9e3'
KOLIBRI_0_15_BIN = os.path.expanduser(
'~/src/devel/kolibri/venv-0.15/bin/kolibri'
from android.config import ACTIVITY_CLASS_NAME, SERVICE_CLASS_NAME
from jnius import autoclass
import logging
import os
logger = logging.getLogger('main') # __name__)
Log = autoclass('android.util.Log')
class AndroidHandler(logging.Handler):
@dbnicholson
dbnicholson / count-objects.c
Created June 9, 2022 22:21
Count ostree objects
#include <glib.h>
#include <gio/gio.h>
#include <ostree.h>
#include <locale.h>
#include <fcntl.h>
static gchar *opt_repo = NULL;
static gboolean opt_commits = FALSE;
static GOptionEntry entries[] = {
@dbnicholson
dbnicholson / delayserver.py
Created April 11, 2022 17:51
Hack Kolibri content server to delay responses
#!/usr/bin/env python3
from argparse import ArgumentParser
from functools import partial
from http.server import SimpleHTTPRequestHandler, ThreadingHTTPServer
import logging
import os
import time
logger = logging.getLogger(__name__)
@dbnicholson
dbnicholson / rename-exchange.py
Created February 12, 2021 20:11
Python renameat2 RENAME_EXCHANGE wrapper
#!/usr/bin/env python3
import ctypes
import errno
import logging
import os
import tempfile
logger = logging.getLogger(os.path.basename(__file__))
libc = ctypes.CDLL('libc.so.6', use_errno=True)
@dbnicholson
dbnicholson / perf-report.txt
Created November 13, 2020 17:18
ostree commit perf report
# To display the perf.data header info, please use --header/--header-only options.
#
#
# Total Lost Samples: 0
#
# Samples: 50K of event 'cycles'
# Event count (approx.): 41854790785
#
# Overhead Command Shared Object Symbol
# ........ ....... .......................... .................................................
@dbnicholson
dbnicholson / all-flatpak-metadata
Last active May 11, 2020 19:22
Dump metadata for all flatpaks from all remotes
#!/usr/bin/env python3
from argparse import ArgumentParser
import gi
import os
gi.require_version('Flatpak', '1.0')
from gi.repository import Flatpak # noqa: E402
/* Build with:
* cc -o monitor-bug $(pkg-config --cflags --libs gio-unix-2.0) monitor-bug.c
*/
#include <locale.h>
#include <sys/types.h>
#include <unistd.h>
#include <err.h>
#include <signal.h>
#include <glib.h>

Keybase proof

I hereby claim:

  • I am dbnicholson on github.
  • I am dbn (https://keybase.io/dbn) on keybase.
  • I have a public key ASBgxdZ3UmgeBfQCg0RDcIaZdxm0p-BdpFwl16Lz3MYf9go

To claim this, I am signing this object:

#!/usr/bin/python3 -u
from argparse import ArgumentParser
from collections import defaultdict
from gi import require_version
require_version('OSTree', '1.0')
from gi.repository import GLib, Gio, OSTree
import sys
def commit_describe(repo, checksum, all_refs=True):