Skip to content

Instantly share code, notes, and snippets.

View metatoaster's full-sized avatar

Tommy Yu metatoaster

  • Auckland Bioengineering Institute, University of Auckland
  • Auckland, New Zealand
View GitHub Profile
@metatoaster
metatoaster / gentoo_install.sh
Last active January 26, 2018 12:41
Install Gentoo with these three easy commands after booting the live CD
mkdir /root/.ssh && cat > /root/.ssh/authorized_keys # type your ssh keys here, finish by hitting enter and ctrl-d; alternatively replace it with a less interactive command
parted --script /dev/sda mklabel gpt mkpart primary 0 1MB mkpart primary 1MB 100% set 1 bios_grub on && mkfs.ext4 /dev/sda2 && mount /dev/sda2 /mnt/gentoo && curl -s http://distfiles.gentoo.org/releases/amd64/autobuilds/`curl -s http://distfiles.gentoo.org/releases/amd64/autobuilds/latest-stage3-amd64.txt | tail -n1 |cut -f1 -d\ ` | tar xpJf - --xattrs-include='*.*' --numeric-owner -C /mnt/gentoo && mount -t proc proc /mnt/gentoo/proc && mount -R /dev /mnt/gentoo/dev && mount -R /sys /mnt/gentoo/sys && cp -L /etc/resolv.conf /mnt/gentoo/etc/ && cp -a /root/.ssh /mnt/gentoo/root/ && chroot /mnt/gentoo /bin/bash -c 'source /etc/profile && emerge-webrsync && emerge --update --deep --newuse @world && emerge app-admin/syslog-ng net-misc/dhcpcd sys-apps/mlocate sys-boot/grub:2 sys-kernel/genkernel-next sys-kernel/gentoo-sources sys-process/cro
# -*- coding: utf-8 -*-
"""
Keyboard to scancode mapping for US keyboard layout.
"""
from itertools import chain
keys_base = (
'`1234567890-='
'qwertyuiop[]\\'
def fizzbuzz():
import random
def magic(number=24866068):
while True:
random.seed(number)
for x in range(15):
n = int(random.random() * 10000) % 4
yield 'fizzbuzz'[(n*4-4)%8:n*4]
@metatoaster
metatoaster / capslockhddled.py
Last active October 12, 2020 12:25
Caps lock LED for HDD Activity
#!/usr/bin/env python
"""
Make Caps Lock LED to show HDD activity, for Xorg/X11 on Linux
This Python script uses ctypes on the libX11 shared object, /proc/vmstat
pseudo-file provided by the Linux kernel to turn a keyboard's caps lock
light to act like a HDD activity LED.
The LED to be controlled must have allowExplicit enabled. Easiest way
to achieve this is to write out a xkbcomp configuration file and replace
@metatoaster
metatoaster / looptest.js
Last active February 16, 2017 23:15
Not immediately wrong looking for loop
// not very obviously wrong looking function
var for_test_func = function(outer, inner, obj) {
for (var i in obj) {
outer(i, function() {
inner(obj[i]);
});
}
};
@metatoaster
metatoaster / pevents.conf
Created January 20, 2017 07:42
XChat2 look and feel in Hexchat
event_name=Add Notify
event_text=-%C26-%C27-%O$t$1 added to notify list.
event_name=Ban List
event_text=-%C26-%C27-%O$t$1 Banlist: %C19$4 %C20$2 %C21$3%O
event_name=Banned
event_text=-%C26-%C27-%O$tCannot join%C27 %B$1 %O(You are banned).
event_name=Beep
"""
Simple Python HTTP server with option to override specific endpoints to
be proxies of external content through the requests library. Intended
use case for this small script is for quick prototyping of specific
single page web applications where specific web resources hosted by
third parties are restricted by cross-origin policies which is a
standard security feature provided by web browsers which restricts
access of http URLs from a file:// url which is used for local
development
(undefined+'')[4]+(undefined+'')[0]+(''.sub+'')[9/3]+(''.strike+'')[13]+(([]).join+'')[9]+(''.anchor+'')[9]+
(eval+'').slice(10,12)+(false+'')[3]+(''.concat+'')[9]+(''+undefined)[5]+([].push+'')[9]+((1/0)+'')[6]
@metatoaster
metatoaster / git-rebase-release.rst
Last active September 21, 2016 03:14
Git Rebase Release

Typically workflow is like this for a release

$ git checkout master -b 0.1.x  # or whatever version number

Things get done, version number get set up.

@metatoaster
metatoaster / mkpypi.release.sh
Created September 7, 2016 07:43
Sick of forgetting to clean dir before running bdist_wheel/sdist
#!/bin/sh
PYSRC=/usr/bin/python3.4
TMPROOT=/tmp
P=$(readlink -f "$1")
REPO=${P}/.git
if [ ! -d $REPO ]; then
echo "Need a repo"
exit