Skip to content

Instantly share code, notes, and snippets.

View Apsu's full-sized avatar

Eve Apsu

  • Lambda Labs
  • Pittsburgh, PA
View GitHub Profile
@Apsu
Apsu / blutil
Last active October 1, 2015 03:48
Backlight control with smooth transitions
#!/usr/bin/env bash
adjust() {
delay=0.01
bl_base=$2
cur_br=$(cat $bl_base/brightness)
min_br=0
max_br=$(cat $bl_base/max_brightness)

General

  • Suitcase
  • Backpacks
  • Laptops
  • Hand cream
  • Kleenex
  • Drinks

Living Room

  • Lamps
  • Rolling carts
@Apsu
Apsu / soundex.py
Created July 7, 2012 04:03
One-line Soundex code generator using functional programming and python hackery
from functools import reduce # Needed for Python 3.x
from operator import add
def soundex(letters, duplicates=False, initial=True, size=4,
sounds=[('aeiouyhw', ''), ('bfpv', '1'), ('cgjkqsxz', '2'), ('dt', '3'), ('l', '4'), ('mn', '5'), ('r', '6')]):
return '0'*size if not len(letters) else ((letters[0] if initial else '') +
reduce(lambda stack, next: stack+next if stack[-1:] != next or duplicates else stack,
map(lambda letter: reduce(add, (val for (key,val) in sounds if letter in key), ''), letters[1:]), ''))[:size if size else None].ljust(size, '0')
@Apsu
Apsu / m-audio_ftpro.patch
Created July 7, 2012 04:06
M-Audio FastTrack Pro 48/96kHz 24-bit kernel patch
--- original/linux-2.6.38.4/sound/usb/quirks.c 2011-04-21 16:34:46.000000000 -0500
+++ new/linux-2.6.38.4/sound/usb/quirks.c 2011-04-23 20:32:19.486586452 -0500
@@ -427,16 +427,17 @@
/*
* Setup quirks
*/
-#define AUDIOPHILE_SET 0x01 /* if set, parse device_setup */
-#define AUDIOPHILE_SET_DTS 0x02 /* if set, enable DTS Digital Output */
-#define AUDIOPHILE_SET_96K 0x04 /* 48-96KHz rate if set, 8-48KHz otherwise */
-#define AUDIOPHILE_SET_24B 0x08 /* 24bits sample if set, 16bits otherwise */
@Apsu
Apsu / 10-display.rules
Created August 23, 2012 05:40
drm udev rule
ACTION=="change", SUBSYSTEM=="drm", ENV{HOTPLUG}=="1", RUN+="display"
@Apsu
Apsu / infuse.py
Last active October 9, 2015 11:13
Destiny Infusion Path Calculator
#!/usr/bin/env python3
import argparse
import functools
import itertools
# Legendary Mark cost per infusion
COST = 3
@Apsu
Apsu / data.md
Last active October 9, 2015 16:08
Infusion Data Points
@Apsu
Apsu / frames.el
Created October 7, 2012 23:23
Emacs settings for make-buffer -> new frame
(setq pop-up-frames "graphic-only")
(setq completion-show-help nil)
(setq ido-completion-buffer nil)
@Apsu
Apsu / test.c
Created October 12, 2012 04:09
Void pointers
#include <stdio.h>
struct data {
int fd;
};
void test(void *d) {
struct data *x = (struct data *)d; // Cast the other way
printf("fd = %d\n", x->fd); // Dereference
}
@Apsu
Apsu / check-veths.sh
Last active December 4, 2015 03:06
Find veth pairs on the host which are not in any running containers
#!/usr/bin/env bash
# Create associative arrays
declare -A interior=()
declare -A exterior=()
# Make sure ethtool is installed on this host
apt-get install -y ethtool &>/dev/null
# For each container