Skip to content

Instantly share code, notes, and snippets.

@ph1ee
ph1ee / splitter.py
Last active March 9, 2020 08:42
ALT1160 flash image splitter
#!/usr/bin/env python3
from collections import namedtuple
from re import compile as regex
import sys
Part = namedtuple('Part', 'name, size, offset')
class Flashdump(object):
@ph1ee
ph1ee / unhexlify-socat.py
Last active January 18, 2019 04:45
unhexlify socat -x -v format
#!/usr/bin/env python3
import sys
import os
from codecs import decode
from re import compile as regex
from enum import Enum
DEBUG = True if os.getenv("DEBUG") else False
@ph1ee
ph1ee / bookmark.py
Last active January 3, 2019 04:19
utility script to bookmark a directory into GNOME Nautilus Places
#!/usr/bin/env python
import sys
import os
import urllib as ul
def main(dir):
places = "{:s}/.config/gtk-3.0/bookmarks".format(os.getenv("HOME"))
with open(places, "a") as f:
@ph1ee
ph1ee / fc-search-codepoint
Last active August 30, 2018 07:51
Find the fonts containing the code point(s) with python-fontconfig
#!/usr/bin/env python2
# https://unix.stackexchange.com/a/268286/247080
import re
import sys
import fontconfig
if len(sys.argv) < 1:
print('''Usage: ''' + sys.argv[0] + '''CHARS [REGEX]
Print the names of available fonts containing the code point(s) CHARS.
@ph1ee
ph1ee / nvim-terminal-edit.py
Created August 24, 2018 01:33 — forked from tarruda/nvim-terminal-edit.py
Edit file in host Neovim instance from a :terminal buffer
#!/usr/bin/env python
"""Edit a file in the host nvim instance."""
import os
import sys
from neovim import attach
args = sys.argv[1:]
if not args:
print "Usage: {} <filename> ...".format(sys.argv[0])
@ph1ee
ph1ee / dtor-memleak.cc
Last active August 17, 2017 11:26
memory leak may occur if a base class destructor is NOT virtual
#include <iostream>
// http://www.gotw.ca/publications/mill18.htm
// Virtual Question #2: What About Base Class Destructors?
using namespace std;
namespace good {
class Base {
public:
@ph1ee
ph1ee / base16dec.py
Last active September 19, 2018 03:25
Simple utility to decode base16-encoded strings
#!/usr/bin/env python
from __future__ import print_function
import sys
import argparse
import fileinput
import base64
def main():
@ph1ee
ph1ee / buildlog
Created April 20, 2017 07:42
LEDE QEMU Virtual Machine Buildlog
make[1] world
make[2] tools/compile
make[3] -C tools/flock compile
make[3] -C tools/sed compile
make[3] -C tools/xz compile
make[3] -C tools/tar compile
make[3] -C tools/patch compile
make[3] -C tools/m4 compile
make[3] -C tools/autoconf compile
make[3] -C tools/pkg-config compile
@ph1ee
ph1ee / colortest.pl
Last active March 23, 2017 02:42
XTERM 256Color Test Chart
#!/usr/bin/perl
# by entheon, do whatever the hell you want with this file
print "\n";
print "**************************\n";
print "*XTERM 256Color Test Chart\n";
print "**************************\n";
print "* 16 = black\n";
print "* 255 = white\n";
@ph1ee
ph1ee / abstract-addr.c
Last active October 3, 2017 03:54
testing abstract unix domain socket address
#include <stdio.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
#include <stdlib.h>
int create_abstract_socket(const char *name) {
int sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
if (sockfd < 0) {
return -1;