Skip to content

Instantly share code, notes, and snippets.

@marxjohnson
marxjohnson / latitude.js
Last active April 14, 2016 17:36
Ubuntu podcast latitude script
(function(){
var map = document.getElementById('map');
var error = document.getElementById('error');
var urlstub = "http://www.openstreetmap.org/export/embed.html?";
function updateMap() {
var request = new XMLHttpRequest();
request.open('GET', 'latitudefile.txt', true);
request.onload = function() {
@marxjohnson
marxjohnson / psd.conf
Created June 11, 2015 10:42
Profile sync daemon Upstart Session Job
description "Profile Sync Daemon"
start on desktop-start
stop on desktop-end
post-start exec sudo /usr/bin/psd sync
post-stop exec sudo /usr/bin/psd unsync
@marxjohnson
marxjohnson / remove-old-kernels.sh
Last active May 27, 2021 11:54
Delete old kernel on debian/ubuntu
#!/bin/bash
# 1. Find all the packages that have installed something in /boot
# 2. Trim it down to just the kernel packages (e.g. remove memtest)
# 3. Sort them oldest->newest
# 4. Remove the newest (so we've got the updated kernel to boot into)
# 5. Remove the current kernel (so we can go back to that if the new one fails)
# 6. Pass the package list to apt-get remove for uninstallation
# Note: This code will only simulate removal. Remove -s flag from apt-get to do it for real.
@marxjohnson
marxjohnson / evtest.log
Created August 18, 2014 17:22
evtest dump for wavebird controller X axis
Input driver version is 1.0.1
Input device ID: bus 0x3 vendor 0x1a34 product 0xf705 version 0x110
Input device name: "HuiJia USB GamePad"
Supported events:
Event type 0 (EV_SYN)
Event type 1 (EV_KEY)
Event code 288 (BTN_TRIGGER)
Event code 289 (BTN_THUMB)
Event code 290 (BTN_THUMB2)
Event code 291 (BTN_TOP)
@marxjohnson
marxjohnson / post-record
Last active November 24, 2016 20:00
Post-record shutdown script for TVheadEnd/XBMC PVR
#!/bin/bash
ruby /usr/local/bin/post-record.rb >> /home/xbmc/wakeup.log 2>&1
@marxjohnson
marxjohnson / wakeup.sh
Created May 7, 2014 18:17
wakeup.sh for XBMC/TvHeadEnd PVR
#!/bin/bash
echo "Executing Wakeup Script" >> /home/xbmc/wakeup.log
echo $1 >> /home/xbmc/wakeup.log
echo 0 > /sys/class/rtc/rtc0/wakealarm
echo $1 > /sys/class/rtc/rtc0/wakealarm
cat /sys/class/rtc/rtc0/wakealarm >> /home/xbmc/wakeup.log
@marxjohnson
marxjohnson / hwclock-save.conf
Last active August 29, 2015 14:01
/etc/init/hwclock-save.conf for Ubuntu 12.04 with ACPI Wakealarm enabled
# hwclock-save - save system clock to hardware clock
#
# This task saves the time from the system clock back to the hardware
# clock on shutdown.
description "save system clock to hardware clock"
start on runlevel [06]
task
@marxjohnson
marxjohnson / post-record
Last active November 24, 2016 19:58
XBMC/Tvheadend post-record shutdown script
#!/usr/bin/env ruby
require 'net/http'
require 'json'
uri = URI 'http://localhost:8080/jsonrpc'
jsonrpc = Net::HTTP::Post.new uri
jsonrpc.add_field 'Content-Type', 'application/json'
jsonrpc.add_field 'Accept', 'application/json'
@marxjohnson
marxjohnson / gist:9311206
Created March 2, 2014 18:28
Outline of my Amazon/Lovefilm Instant Video-on-Ubuntu solution
Previous solution used Pipelight, which was much nicer. However, since Amazon ate Lovefilm, the player doesn't work with pipelight. So..
2 Profiles:
xbmc (XBMC session, auto login, no password)
lovefilm (Openbox session, no password)
Menu item in XBMC triggers session switch to Lovefilm (uses dm-tool)
On login, Lovefilm automatically launches Windows 7 VM in virtualbox, full screen, automatically logs in and runs Firefox fullscreen (or just loads saved state if there is one).
User watches stuff with silverlight. When finished, they close VirtualBox using "X" icon on pop-up menu bar.
When Virtualbox is closed, dm-tool is automatically invoked to return user to XBMC, and all remaining processes belonging to lovefilm are killed with pkill.
@marxjohnson
marxjohnson / gist:5856890
Last active December 18, 2015 22:48
PHP finally keyword
<?php
function throw_exception() {
// Arbitrary code here
throw new Exception('Hello, Joe!');
}
function some_code() {
// Arbitrary code here
}