Skip to content

Instantly share code, notes, and snippets.

View u8sand's full-sized avatar

Daniel J. B. Clarke u8sand

View GitHub Profile
@u8sand
u8sand / .conkyrc
Created August 26, 2016 15:58
My conky configuration
background yes
font Inconsolata:size=9
use_xft yes
xftalpha 0.8
update_interval 2.5
total_run_times 0
own_window yes
own_window_type override
own_window_transparent yes
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
@u8sand
u8sand / autoupdate.cpp
Last active October 26, 2016 14:32
A proof of concept auto-update mechanism
// Auto-update proof of concept
// embedding the update step into the
// current and new executables ahead of
// time, we don't need any extra scripts.
// It works by calling the new executable
// to rename the old one, and call the
// old one to rename the new one, execute
// it and exit. Finally the renamed new
// one removes the old one and runs normally.
// Process:
@u8sand
u8sand / post-receive
Created November 9, 2016 18:05
github.io-like Jekyll hook
#!/bin/bash
# Note that this goes under your github bare repo /hooks/
work=$(mktemp -d)
out=/http/
jekyll=/usr/share/ruby/2.3.0/bin/jekyll
while read oldrev newrev refname
do
branch=`echo $refname | cut -d/ -f3`
@u8sand
u8sand / fixlinks
Created January 12, 2017 16:54
Bookmark for eliminating intermediary links on certain sites. `http://middleman?url=http://actualurl/` -> `http://actualurl/`
@u8sand
u8sand / rank-mirror-list
Created January 20, 2017 03:34
Script for ranking the mirrorlist.pacnew files that are updated every once in a while.
#!/bin/bash
if [ $(id -u) != 0 ]; then
exec sudo -- "$0" "$@"
else
cat /etc/pacman.d/mirrorlist.pacnew | awk -v RS='\n\n' '/^## United States/{print $0}' | awk '/^#Server/{print substr($0, 2)}' | rankmirrors - > /etc/pacman.d/mirrorlist
rm /etc/pacman.d/mirrorlist.pacnew
fi
@u8sand
u8sand / enforce.py
Last active August 13, 2017 21:06
Enforce new python3.6 type decorators at runtime with this decorator.
#!/bin/env python
def enforce(func):
''' Decorator to enforce type decorators at runtime via
type assertion. Usage:
@enforce
def foo(a : str, b : int, c = True : bool) -> str:
return None
'''
def enforce_wrapper(*args, **kwargs):
@u8sand
u8sand / PKGBUILD
Last active July 29, 2018 09:51
Process the archlinux pacman mirrorlist for US
pkgname=('pacman-mirrorlist-hook')
pkgver=1
pkgrel=1
pkgdesc='Pacman mirrorlist hook.'
arch=('any')
depends=('pacman' 'pacman-mirrorlist')
source=('pacman-mirrorlist.hook' 'rank-mirror-list.sh')
md5sums=('b51e1a45b23b2831709e7732fe88d4c8'
'5cceded6741d705fd09b919de9e1234b')
@u8sand
u8sand / Dockerfile
Last active February 8, 2022 04:14
Docker u8sand/archlinux-devel-yaourt (https://hub.docker.com/r/u8sand/archlinux-devel-yaourt/)
# Usage:
#FROM u8sand/archlinux-devel-yaourt
#RUN echo "Instaling dependencies..."
#RUN pacman -Sy --noconfirm && sudo -u docker yaourt -S --noconfirm all your packages
#
# Your scripts
#
#Optional: Remove privileged account for security reasons
#RUN userdel -r docker && rm /etc/sudoers.d/docker
@u8sand
u8sand / every_env.sh
Last active May 16, 2019 20:09
Script for installing a suite of local version managers for python, node, and ruby (pyenv, rbenv, nodenv)
#!/bin/sh
HOME="/home/${USER}"
PROFILE="${HOME}/.profile"
install_env() {
ENV_CMD="$1"
ENV_URL="$2"
ENV_ROOT="${HOME}/.${ENV_CMD}"
ENV_CMD_ROOT="$(echo ${ENV_CMD} | tr /a-z/ /A-Z/)_ROOT"
@u8sand
u8sand / parse_uri
Created March 4, 2018 14:51
Perl-based uri parser for bash scripts
#!/usr/bin/env sh
# Parse a normal uri--e.g. http://user:pass@host:1234 into a custom perl-based substitution format.
# e.g. parse_uri "http://localhost:80" '$+{port}' ==> 80
function parse_uri() {
URI=$1
FMT=$2
echo ${URI} | perl -pe "s#(?<proto>[\w\+-]+)://((?<user>[-\w]+):(?<pass>[-\w]+)@)?((?<host>[-\w]+)(:(?<port>\d+))?)#${FMT}#g"
}