Skip to content

Instantly share code, notes, and snippets.

View tremby's full-sized avatar

Bart Nagel tremby

View GitHub Profile
@tremby
tremby / gist:1571699
Created January 6, 2012 18:07
screens -- switch screens on or off
#!/bin/bash
function usage {
echo "Usage: $(basename $0) {off|on}"
exit 1
}
if [ ! $DISPLAY ]; then
echo "DISPLAY is not set" >&2
exit 1
fi
if [ $# -ne 1 ]; then
@tremby
tremby / gist:1571701
Created January 6, 2012 18:08
topleft -- move mouse pointer to top left of current screen
#!/bin/bash
# check for binaries
type -P xmousepos &>/dev/null || {
echo "can't find xmousepos -- install xautomation" >&2
exit 1
}
type -P xte &>/dev/null || {
echo "can't find xte -- install xautomation" >&2
exit 1
@tremby
tremby / gist:1571705
Created January 6, 2012 18:08
wp -- set random or specified wallpaper for nitrogen
#!/bin/bash
WPDIR="$HOME/images/wallpaper"
random=true
apply=true
wpfile=""
function usage {
if [ $1 -eq 1 ]; then
@tremby
tremby / choosealbumart.py
Created January 16, 2012 23:29
choose between duplicate album art
import os
import sys
import subprocess
import pygtk
import gtk
class Chooser:
def __init__(self):
self.win = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.win.connect("delete_event", self.quit)
@tremby
tremby / aa.sh
Created January 17, 2012 01:26
view album art
#!/bin/bash
# aa -- view album art
# Expects either no argument (and will then query for the currently playing
# song according to MPD) or one argument which is the path to a music file.
#
# Expects to find a file titled something like cover.jpg (see prefixes,
# middles, suffixes below) in the same directory as the music file. If found an
# image viewer is launched. If no DISPLAY is available, use img2txt to get
# ASCII art if available.
@tremby
tremby / volume.py
Created June 18, 2012 07:05
volume
This has moved to https://github.com/tremby/pulse-volume
# fadefactor is a short method which returns a float based on the one passed in
# audio is a bytearray
for i in range(fadeinframes):
offset = i * framesize
frame = str(audio[offset:offset + framesize])
value = struct.unpack(frameformat, frame)
audio[offset:offset + framesize] = struct.pack(frameformat,
*(fadefactor(float(i) / fadeinframes) * v for v in value))
@tremby
tremby / gbdvorak.keylayout
Created May 21, 2013 20:44
United Kingdom Dvorak 105-key keyboard layout file for Mac OS X. Put it in ~/Library/Keyboard Layouts, clear the cache (sudo rm /System/Library/Caches/com.apple.IntlDataCache*; sudo find /var -name "*IntlDataCache*" -delete) and then it should be in the keyboard layouts list as GB Dvorak.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE keyboard PUBLIC "" "file://localhost/System/Library/DTDs/KeyboardLayout.dtd">
<!--Created by Ukelele version 2.2.4 on 2013-05-21 at 12:51 (PDT)-->
<!--Last edited by Ukelele version 2.2.4 on 2013-05-21 at 13:33 (PDT)-->
<keyboard group="0" id="5591" name="GB Dvorak" maxout="1">
<layouts>
<layout first="0" last="0" modifiers="f4" mapSet="a14"/>
<layout first="18" last="18" modifiers="f4" mapSet="1fc"/>
<layout first="21" last="23" modifiers="f4" mapSet="1fc"/>
<layout first="30" last="30" modifiers="f4" mapSet="1fc"/>
@tremby
tremby / gist:6454674
Created September 5, 2013 19:09
Raphael ellipse resizing
handleDragMove = (dx, dy, mouseX, mouseY) ->
angleEllipse = $canvas.data 'rotation'
centreToMouseX = mouseX - ($canvas.offset().left + ellipse.attr('cx'))
centreToMouseY = mouseY - ($canvas.offset().top + ellipse.attr('cy'))
centreToMouse = Math.sqrt(Math.pow(centreToMouseX, 2) + Math.pow(centreToMouseY, 2))
angleMouse = Math.atan2(centreToMouseY, centreToMouseX)
if @data 'horizontal'
updateShapes
rx: Math.abs(centreToMouse * Math.cos(angleMouse - angleEllipse))
else
@tremby
tremby / gist:6644465
Last active December 23, 2015 13:49
Jquery plugins to provide recursive bounds, height and width calculators for elements
# Get the bounds of elements including all children relative to the document
# - The visibility property is totally ignored whether visible or hidden
# - Elements with display: none are skipped
# - Horizontal bounds of children are ignored when overflow-x is hidden
# - Vertical bounds of children are ignored when overflow-y is hidden
$.fn.getBounds = ->
bounds =
left: Infinity
right: -Infinity
top: Infinity