Skip to content

Instantly share code, notes, and snippets.

View hunner's full-sized avatar

Hunter Haugen hunner

View GitHub Profile
#!/usr/bin/env python
"""
Last.fm scrobbling for Pianobar, the command-line Pandora client. Requires Pianobar, Python, pyLast and Last.fm API credentials.
https://github.com/PromyLOPh/pianobar/
http://code.google.com/p/pylast/
http://www.last.fm/api/account
Installation:
1) Copy this script and pylast.py to the Pianobar config directory, ~/.config/pianobar/, and make sure this script is executable
@hunner
hunner / xbacklight.sh
Created November 2, 2015 18:32
xbacklight shell script replacement for gmux (ie, apple macbook pro)
#!/bin/sh
brightness=$(cat /sys/class/backlight/gmux_backlight/brightness)
if [ $1 = '-inc' ] ; then
newbrightness=$(expr $brightness + $2 \* 3)
elif [ $1 = '-dec' ] ; then
newbrightness=$(expr $brightness - $2 \* 3)
fi
if [ $newbrightness -lt 0 ] ; then
@hunner
hunner / id_dsa.pub
Created July 17, 2012 21:59
Hunter Haugen (Hunner) DSA pub key
ssh-dss AAAAB3NzaC1kc3MAAACBALoCwmgFrZs1FpqOoVhOvbrUviydoOXrPCNlF5sgh2o09b38mjkJE11mkvyzdfqaOyyphbjKGWbyhnbJrqbj5cPrYsVa1/8FG8JCTKK8PB93MIGfji0WogMsFXJKvIeWtW8eD71Es2roxNe4sbVCY7m51akfD+CJv6q8eMpTAVmhAAAAFQDDC8KCAhtXt/uiZUvNywKpmQGBlQAAAIAH8CQLTo9MF2qLsqPJfvvEAI6WAj5bDvTS2HGXjwsEeH2XJmbH02kqOylDyZ/N/7hCc/6E6IkFPfb2z326HmU/bwZG7WWPDsXjOkC24QxTkw0j0s7Nl69gWvDqsTAmWivqpgYInffVpTEWClk4D6xnn7il+ZZ78EAbWpkO0YJJkQAAAIAPpnh/ngE7Pf6Sss/E+RuNIg17BCy/q9BbPUly20WnVtZkezdcZwaKBsyyuoHEqiN6dK4ZW+m3EYCUVDf+fLH3DT11lMGBN+RiF7peXI/rJcXJIzlITypcWvkxSkZ8zN+Lmb6moc4o8sjr1O5KC1H+CDduN72XLYegLS/O1qxp+w== hunter@puppetlabs.com
@hunner
hunner / example_spec.rb
Last active May 17, 2018 11:53
Example code for beaker-rspec on master & agent
# This is what a test would look like.
require 'spec_helper_acceptance'
describe 'some class' do
it 'does stuff' do
pp=<<-EOS
notify { 'done stuff spec':
message => 'This message should appear',
}
EOS
require 'json'
class Hunner
end
class Hunner::Render < Redcarpet::Render::Base
# Add manifest introspection for parameters
# Do we really want hash keys?
# Error on duplicate keys
# Define a spec which they should adhere to (Check against rendered structure)
attr_accessor :last_header
attr_accessor :last_level
include postgresql::server
# fails because you can't override from outside a class
Fail['/var/lib/postgresql9.5/datadir'] {
mode => '0755',
}
# succeeds because inheritance lets you override, but inheritance is spaghetti code
class test inherits postgresql::server::initdb {
File['/var/lib/postgresql9.5/datadir'] {
mode => '0755',
@hunner
hunner / bashbot.sh
Created May 31, 2014 01:42
Bash irc bot
#!/usr/bin/env bash
line=""
started=""
rm botfile
mkfifo botfile
tail -f botfile | nc irc.cat.pdx.edu 6667 | while true ; do
if [ -z $started ] ; then
echo "USER bdbot 0 bdbot :I iz a bot" > botfile
echo "NICK bdbot" >> botfile
@hunner
hunner / Vagrantfile
Last active February 19, 2017 01:54
Vagrantfile example with vagrant-hosts and vagrant-auto_network
Vagrant.configure('2') do |config|
# Specify box files
config.vm.box = 'precise32'
config.vm.box_url = 'http://files.vagrantup.com/precise32.box'
# Create web frontend
config.vm.define 'web.example.com' do |node|
node.vm.network :forwarded_port, guest: 443, host: 4443
node.vm.network :forwarded_port, guest: 80, host: 8080
$file_defaults = {
mode => '0600',
owner => 'root',
group => 'root',
ensure => file,
}
file {'/etc/ssh_host_dsa_key':
* => $file_defaults,
}
file { '/etc/ssh_host_key':
@hunner
hunner / .gitconfig
Last active September 26, 2016 09:25
Pretty format `git lg`
[alias]
# See http://cat.pdx.edu/~hunner/git-lg.png for an example
lg = "log --decorate --pretty=format:'%C(yellow)%h%C(reset) %C(green)%G?%C(reset) %C(blue)%an%C(reset) %C(cyan)%cr%C(reset) %s %C(auto)%d%C(reset)' --graph --date-order"