Skip to content

Instantly share code, notes, and snippets.

@cheshirekow
cheshirekow / close-git-bugs
Last active October 25, 2019 20:55
Close `git-bug` bugs based on entries in git commit messages
#!/usr/bin/env python
"""
Close git-bugs based on meta-data from commit messages in a repository.
"""
import argparse
import logging
import os
import subprocess
import sys
@cheshirekow
cheshirekow / post_ip_to_slack.cc
Created February 21, 2019 17:07
Post your IP addresses to slack. Useful to run on-boot.
// Copyright 2019 Josh Bialkowski <josh.bialkowski@gmail.com>
#include <fcntl.h>
#include <ifaddrs.h>
#include <net/if.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
@cheshirekow
cheshirekow / bt-connect-headset
Created September 28, 2018 21:53
Script to force ubuntu to connect to an already paired bluetooth headset.
#!/usr/bin/env python
# Toggles headset connection
from __future__ import print_function
from __future__ import unicode_literals
# Original solution found here:
# https://askubuntu.com/questions/48001
# /connect-to-bluetooth-device-from-command-line
@cheshirekow
cheshirekow / bitfield.py
Created May 31, 2018 21:28
Simple BitField in python
class BitMember(object):
def __init__(self, size, offset=0):
self.size = size
self.offset = offset
@property
def mask(self):
return ~((~0) << (self.offset + self.size)) & ((~0) << self.offset)
#!/usr/bin/python
"""
Resolve phandle references from a device tree capture.
"""
import argparse
import logging
import sys
def get_phandle_map(infile):
@cheshirekow
cheshirekow / imgclip.py
Created August 4, 2017 04:27
Gtk command line clipboard for images
#!/usr/bin/python
"""Command line control of images in your clipboard."""
import argparse
import os
import sys
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk, GdkPixbuf
@cheshirekow
cheshirekow / user_chroot.cc
Created October 26, 2016 20:19
Simple POC program to to demonstrate chroot without root using user namespaces.
// g++ -o user_chroot user_chroot.cc
// references:
// [1]: http://man7.org/linux/man-pages/man7/user_namespaces.7.html
// [2]: http://man7.org/linux/man-pages/man2/unshare.2.html
#include <sched.h>
#include <sys/types.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>