Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
set -e
set -o pipefail
function list_tars {
ROOT=$1
TAG=${2:-latest}
BASE=$(sed -e 's/.*{\(".*"\)}.*/\1/g' "${ROOT}/repositories" | sed 's/"//g' | awk -v RS=',' -F: '/^'${TAG}'/ {print $2}')
CUR=$BASE
@dirkakrid
dirkakrid / tar-docker-image
Created October 29, 2016 23:58 — forked from aputs/tar-docker-image
tar docker image (squash)
docker_root=/var/lib/docker/btrfs
subvolumes=subvolumes
docker_image=aputs/archlinux
tar_file=/tmp/image.tar.gz
# tar
cd $docker_root/$subvolumes/$(docker inspect --format='{{.Id}}' $docker_image)
tar --exclude={'.','..'} -Pcvzf $tar_file .* *
@dirkakrid
dirkakrid / README.md
Created October 29, 2016 23:51 — forked from blalor/README.md
Bulk move messages from All Mail to Trash

I hate GMail, but sometimes you gotta. They're notoriously awful at deleting lots of messages at once, as their own search engine will tell you. I had more than 1,000,000 messages I needed to purge and couldn't do it using their own tools. So I wrote my own.

@dirkakrid
dirkakrid / systemd-nspawn
Created October 29, 2016 23:49 — forked from blalor/systemd-nspawn
systemd-nspawn replacement [containers/build#162]
#!/usr/bin/env bash
## this is a total hack. acbuild needs systemd-nspawn. initially, I tried
## running the go agent in a rkt container, but failed for reasons I forget
## right now (overlayfs problems?). then I ran into more problems with systemd-
## nspawn on CentOS 7.1, and I forget the origin. we're getting closer: in
## CentOS 7.2 I'm able to run acbuild as root outside of a container. but when
## running within the go agent, systemd-nspawn is killed for no discernable
## reason. so, we're back to faking out acbuild by providing this systemd-
## nspawn-alike.
@dirkakrid
dirkakrid / openjdk
Created October 29, 2016 17:14 — forked from yrps/openjdk
systemd-nspawn launcher for Java applications
#!/bin/sh
set -eu
container="$(basename "$0")"
program="$1"
shift
# logname returns the user calling sudo
host_user="$(logname)"
@dirkakrid
dirkakrid / !OpenELEC Container README.md
Created October 29, 2016 17:03 — forked from hobbsAU/!OpenELEC Container README.md
OpenElec systemd-nspawn Container

Description

OpenELEC runs Kodi, an award-winning free and open source (GPL) software media player and entertainment hub for digital media. For more info see http://kodi.tv . The base system has been designed and built from the ground up to be as efficient as possible – consuming only tiny disk and memory footprints and providing cutting edge hardware support to deliver a set-top box experience.

In order to run software above the base OpenELEC distribution with minimal impact to the OpenELEC base, one alternative is to use a container.

I have chosen to use systemd-nspawn instead of chroot. There are really no downsides as long as you can configure the required kernel config options and have a basic working knowledge of systemd.

Installation

@dirkakrid
dirkakrid / nspawn-container
Created October 29, 2016 16:53 — forked from mopemope/nspawn-container
nspawn-container
#!/bin/bash
TOOLBOX_DOCKER_IMAGE=$1
TOOLBOX_USER=root
machinename=$(echo "${USER}-${TOOLBOX_DOCKER_IMAGE}" | sed -r 's/[^a-zA-Z0-9_.-]/_/g')
machinepath="/var/lib/toolbox/${machinename}"
if [ ! -d ${machinepath} ] || systemctl is-failed ${machinename} ; then
sudo mkdir -p "${machinepath}"
@dirkakrid
dirkakrid / beautiful_idiomatic_python.md
Created October 29, 2016 16:51 — forked from JeffPaine/beautiful_idiomatic_python.md
Transforming Code into Beautiful, Idiomatic Python: notes from Raymond Hettinger's talk at pycon US 2013. The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides.

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]:
# `ref: https://fangpenlin.com/posts/2012/08/26/good-logging-practice-in-python/
import logging
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
# create a file handler
handler = logging.FileHandler('hello.log')
from microbit import *
networkID = 0 # Change the channel variable in the radio.configure to this
def selectNetwork(): # Call this function before calling anything else
global networkID
currentID = networkID
while True:
if button_a.is_pressed() and button_b.is_pressed():
networkID = currentID