Skip to content

Instantly share code, notes, and snippets.

View emmaly's full-sized avatar
💜
Safely dividing by zero in production

Emmaly emmaly

💜
Safely dividing by zero in production
View GitHub Profile
@emmaly
emmaly / gist:8267078
Created January 5, 2014 11:21
Bash script to automatically switch PulseAudio sink to Bluetooth headset on connect with A2DP profile and 50% volume.
#!/bin/bash
sink_name="bluez_sink.00_42_1B_AD_FA_CE"
if [ -z "$1" ]; then
dbus-monitor --system "path=/org/bluez/777/hci0/dev_00_42_1B_AD_FA_CE, interface=org.bluez.AudioSink, member=Connected" | while read line; do
echo $line
$0 1
done
else
#!/bin/bash
# Bind this to a hotkey in your window manager. This will allow you to select
# a rectangle on your screen to store as a PNG file and then puts the path to
# that PNG file into your clipboard. It assumes you want to store the file in
# ~/Pictures/Screenshots, but you can change that yourself in the FILENAME var.
# Requires:
# - imagemagick (provides /usr/bin/import)
# - xclip (provides /usr/bin/xclip)
@emmaly
emmaly / timertest.go
Last active September 15, 2015 02:41
Timer Test
package main
import (
"fmt"
"math/rand"
"sync"
"time"
"github.com/satori/go.uuid"
)
@emmaly
emmaly / deco.go
Created October 1, 2015 09:35
Go Decorator Example
package main
import (
"fmt"
"math/rand"
"time"
)
// An Adder adds two ints and returns an int
type Adder func(a int, b int) int
root@localhost:~# git clone https://go.googlesource.com/go go1.4
Cloning into 'go1.4'...
remote: Sending approximately 105.10 MiB ...
remote: Counting objects: 10095, done
remote: Finding sources: 100% (789/789)
remote: Total 254455 (delta 204262), reused 254270 (delta 204262)
Receiving objects: 100% (254455/254455), 100.71 MiB | 6.12 MiB/s, done.
Resolving deltas: 100% (204262/204262), done.
Checking connectivity... done.
Checking out files: 100% (5464/5464), done.
@emmaly
emmaly / 47625.user.js
Created May 29, 2016 10:18
Hammerfall script
// ==UserScript==
// @name Hammerfall RPG Helper
// @namespace http://hammerfallhelper.dustywilson.com
// @include http://apps.facebook.com/hammerfall/*
// ==/UserScript==
// THIS CODE IS LICENSED GPL. Copyright 2009 Dusty Wilson, http://www.dustywilson.com/
try
{
@emmaly
emmaly / toggletouchpad.sh
Created September 18, 2016 03:04
Toggle TouchPad device in Linux
#!/bin/bash
TOUCHPADDEVICE=$(($(xinput list | grep -i touchpad | cut -d= -f2 | cut -d[ -f1)+0))
TOUCHPADON=$(($(xinput list-props $TOUCHPADDEVICE | grep -i enable | cut -d: -f2)+0))
if [ $TOUCHPADON -eq 1 ]; then
xinput disable $TOUCHPADDEVICE
else
xinput enable $TOUCHPADDEVICE
fi
@emmaly
emmaly / beings.go
Created September 26, 2016 05:58
golang: Interfaces, type casting
package main
import "fmt"
func main() {
bob := NewHuman("Bob")
jim := NewHuman("Jim")
joe := NewHuman("Joe")
bob.Greet(jim)
@emmaly
emmaly / gist:c5e97efcd49468930dcbf9371a85ad86
Created November 24, 2016 08:30
Turris Omnia LED Notes
# to make the LED attributes writable by all users (for example, if writing to them via LXC container non-root users)
chmod 666 /sys/class/leds/omnia-led\:*/{autonomous,brightness,color}
# to make the LEDs controlled via attributes directly:
echo 0 > /sys/class/leds/omnia-led\:user1/autonomous
# replace "user1" with whatever specific LED you're wanting to control
# to set the color: (it's RGB in decimal, not hex)
echo "0 255 0" > /sys/class/leds/omnia-led\:user1/color
@emmaly
emmaly / ps1.sh
Last active March 6, 2017 18:30
My Bash Prompt PS1
dwps_start_fg=0
dwps_start_bg=0
dwps_user_fg=82
dwps_user_bg=235
dwps_usersep_fg=2
dwps_usersep_bg=${dwps_user_bg}
dwps_dir_fg=190
dwps_dir_bg=19
dwps_dirsep_fg=99
dwps_dirsep_fg=9