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-power.rules
Created August 23, 2012 05:38
power_supply udev rule
ACTION=="change", SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="[01]", RUN+="power %E{POWER_SUPPLY_ONLINE}"
@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 / 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 / uefisetup.sh
Last active July 8, 2021 03:54
Arch Linux UEFI Setup
# **************** READ THIS FIRST ******************
#
# This is not a script for you to run. I repeat, do not download and run this!
#
# This is only a guide to show the required steps for successful UEFI + GRUB2 installation
# Many of the choices are examples or assumptions; don't blindly type shit into your machine
# until/unless you at least read the comments around each command
#
# These steps assume you've booted in UEFI mode by preparing your USB stick per these instructions:
# https://wiki.archlinux.org/index.php/UEFI#Archiso
@Apsu
Apsu / display
Created January 2, 2013 21:37
/usr/lib/udev/display dynamic xrandrerer
#!/bin/zsh
for i in /sys/class/drm/card0-*/status; do
d="${${${i#*-}%/*}/(-?-|-)}"
if [[ "$d" == "LVDS1" ]]; then
t="--output LVDS1 --auto --primary$t"
elif [[ "$(<$i)" == "connected" ]]; then
t="$t --output $d --auto --left-of LVDS1"
else