Skip to content

Instantly share code, notes, and snippets.

View kirsle's full-sized avatar

Noah Petherbridge kirsle

View GitHub Profile
@kirsle
kirsle / .bashrc
Created January 17, 2017 21:04
Show current git branch name in Bash prompt
# Function that prints the branch name.
git_branch() {
branch=`git branch 2> /dev/null | sed -e '/^[^*]/d' | perl -pe 's/^\*\s+//g'`
if [ "$branch" != '' ]; then
echo -n " ($branch)"
fi
}
# Integrate it into your $PS1 prompt.
# Would look like: [user@localhost myapp (master)]$
@kirsle
kirsle / nginx-custom
Created January 18, 2017 21:25
Rotate nginx per-user log files
/home/*/logs/*.log {
daily
missingok
rotate 14
size 50M
compress
delaycompress
notifempty
create 0640 www-data adm
sharedscripts
@kirsle
kirsle / Motivational Speech Alarm Clock.md
Last active March 16, 2018 23:51
Motivational Speech Alarm Clock with Raspberry Pi

Motivational Speech Alarm Clock

This is the code I used to make an alarm clock out of a Raspberry Pi (model 1 B+, 512MB RAM) that plays motivational speeches at 6:30 in the morning to get my ass out of bed.

At first I was using a CLI YouTube client, but it would hang after a while due to not running on an interactive console (being launched by crond), and the audio support on Pi's have always been somewhat flaky.

I ended up using youtube-dl to pre-download a playlist and using omxplayer for its hardware-accelerated decoding support. Works pretty well, except omxplayer has no support for things like "playlists" or "shuffling" so I needed

@kirsle
kirsle / attrdict.py
Created July 18, 2014 21:07
AttrDict - A dict for Python that behaves like JavaScript.
#!/usr/bin/env python
"""A dict-like object that supports JS object syntax.
AttrDict is a dict that can be called using either square brackets, like a
normal dict, or by using attributes--just like in JavaScript.
Accessing the value for an undefined key will return None (Python's equivalent
to undefined).
@kirsle
kirsle / README.md
Created March 19, 2020 20:03
Offsite Encrypted Backups

This describes my setup for using DigitalOcean Volumes (disk images attached to my VPS) for off-site backups and keeping them encrypted-at-rest when I'm not actively writing or reading to the disk image.

Basically it consists of:

  • A DigitalOcean virtual private server.
  • An extra Volume attached to the VPS (100GB or so), this presents itself as a block storage device in Linux.
  • LUKS encrypted partition on the Volume.
@kirsle
kirsle / .gtkrc-2.0.md
Created December 21, 2014 05:29
GTK Config for the panel text color on the XFCE Desktop

Save this code as ~/.gtkrc-2.0 and restart your XFCE panel with xfce4-panel -r

This file will set your panel text color to white (overriding the color setting from your current GTK theme). Change the #FFFFFF to another color if you want another color.

The engine "murrine" part will remove the text style for Murrine based themes (for example, a drop-shadow effect used in the Ubuntu Ambiance theme and Greybird).

style "panel"
{
 fg[NORMAL] = "#FFFFFF"
@kirsle
kirsle / decorators.md
Created September 22, 2014 22:29
Python decorator order

What order does Python execute decorators in? It seems like this changed sometime between when they were first introduced (2.4) and now (2.7).

Given the code:

@foo
@bar
@baz
def myfunc():
    pass