Skip to content

Instantly share code, notes, and snippets.

View Qalthos's full-sized avatar

Kate Case Qalthos

View GitHub Profile
@Qalthos
Qalthos / gist:2992335
Created June 26, 2012 00:37
wiki.sugarlabs.org cursor CSS killer
@-moz-document domain('wiki.sugarlabs.org') {
a {
cursor: pointer !important;
}
}
@Qalthos
Qalthos / Knowledge example
Created August 1, 2012 21:22
Example code for using the newly emancipated Knowledge module
#!/usr/bin/env python2
from sqlalchemy import create_engine
from knowledge.model import Fact, Entity, DBSession, init_model, metadata
def inject_knowledge():
knowledge = DBSession
monster = Entity(u'Monster')
fairy = Entity(u'Fairy')
rjbean = Entity(u'rjbean')
monster[u'color'] = u'Green'
#!/bin/sh
# The user that will run the server
CS_USER=hlds
# Leave this alone.
NAME=srcds
PATH=/bin:/usr/bin:/sbin:/usr/sbin
@Qalthos
Qalthos / buzzer.sh
Last active December 18, 2015 18:39
Put somewhere in $PATH and give it the location of buzzer.ogg
#!/bin/bash
vol_perc=$(amixer get Master | egrep -o '[0-9]+%' | head -n 1)
mute=$(amixer get Master | egrep -o '\[off\]' | head -n 1)
amixer -q set Master 100% unmute
mplayer buzzer.ogg
amixer -q set Master $vol_perc $(if [ ! -z $mute ]; then echo 'mute'; fi)
@Qalthos
Qalthos / dep_tree.py
Last active December 21, 2015 11:19
Get detailed dependency information from site packages.
from __future__ import print_function
from pprint import pprint as print
import pip
def get_all_package_dependencies():
"""Return dictionary of installed packages to list of package dependencies."""
return {
dist.key: [(r.key, r.specs) for r in dist.requires()]
for dist in pip.get_installed_distributions()
}
@Qalthos
Qalthos / gist:6889584
Last active December 25, 2015 00:39
eventbrite grab attendees
import eventbrite
eb_tokens = dict(app_key='APPLICATION_KEY')
eb_cl = eventbrite.EventbriteClient(eb_tokens)
response = eb_cl.event_list_attendees(dict(id='8645022495',
only_display='first_name,last_name,answers'))
attendees = list()
for a_dict in response['attendees']:
a_dict = a_dict['attendee']
@Qalthos
Qalthos / gist:9128758
Created February 21, 2014 04:27
re-organize music
#!/usr/bin/env python
from __future__ import unicode_literals, print_function
import os
import re
import mutagen
for path, dirs, files in os.walk('old'):
# Mount drive here
dd if=/dev/zero of=/path/to/mount/zero
# Unmount drive here
sudo dd if=/dev/whatever bs=4k | pv | 7za a -si -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on archive.7z -bd
@Qalthos
Qalthos / backup
Last active August 29, 2015 14:09
Backup all the things
#!/bin/bash
BACKUP=/data/backup/$(hostname)
DATE="$(date '+%Y-%m-%d--%H-%M')"
OPTS='-amxHAX --partial --delete --delete-excluded --exclude-from=.exclude --rsh=ssh --link-dest=../current'
IGNORE_ERROR=(0 23 24)
if [ "$1" == "-v" ]; then
OPTS="$OPTS -vh --progress"
fi
pushd ~ > /dev/null

With connection: network_cli, the provider dictionary is no longer necessary. Here is a quick rundown of provider keys and their variable and commandline equivalents

provider inventory variable commandline
host ansible_host N/A
port ansible_port N/A