Skip to content

Instantly share code, notes, and snippets.

@spinscale
spinscale / volume.lua
Created April 16, 2017 18:19
Hammerspoon: Configure volume via keyboard shortcuts for macbook pro (touchbar, but no keys)
function changeVolume(diff)
return function()
local current = hs.audiodevice.defaultOutputDevice():volume()
local new = math.min(100, math.max(0, math.floor(current + diff)))
if new > 0 then
hs.audiodevice.defaultOutputDevice():setMuted(false)
end
hs.alert.closeAll(0.0)
hs.alert.show("Volume " .. new .. "%", {}, 0.5)
hs.audiodevice.defaultOutputDevice():setVolume(new)
@garronej
garronej / resilio.txt
Last active August 4, 2022 19:43
Install resilio-sync on raspberry pi
mkdir /var/lib/resilio-sync/ && chown pi:pi -R /var/lib/resilio-sync
mkdir /etc/resilio-sync
nano /etc/resilio-sync/config.json
{
"storage_path" : "/var/lib/resilio-sync/",
"pid_file" : "/var/run/resilio-sync/sync.pid",
"webui" :
@subfuzion
subfuzion / .tmux.conf
Last active August 22, 2023 15:33
My .tmux.conf for tmux 2.1 (with fixes for mouse breakage)
# Inspirations:
# http://mutelight.org/practical-tmux
# http://zanshin.net/2013/09/05/my-tmux-configuration/
# http://files.floriancrouzat.net/dotfiles/.tmux.conf
# http://stackoverflow.com/questions/9628435/tmux-status-bar-configuration
# https://github.com/Lokaltog/powerline
# https://github.com/remiprev/teamocil
# http://superuser.com/questions/74492/whats-the-best-prefix-escape-sequence-for-screen-or-tmux
# http://blog.hawkhost.com/2010/07/02/tmux-%E2%80%93-the-terminal-multiplexer-part-2/
#
@simonebaracchi
simonebaracchi / power_saving.ino
Created August 18, 2015 17:20
Routines for power saving on the Arduino. Posted at http://simonebaracchi.eu/posts/arduino-power-cutter/
#include <avr/sleep.h>
#include <avr/power.h>
#include <avr/wdt.h>
// watchdog interrupt
ISR (WDT_vect)
{
wdt_disable(); // disable watchdog
}
@matthewmueller
matthewmueller / osx-for-hackers.sh
Last active April 21, 2024 03:30
OSX for Hackers (Mavericks/Yosemite)
# OSX for Hackers (Mavericks/Yosemite)
#
# Source: https://gist.github.com/brandonb927/3195465
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Ask for the administrator password upfront
@kareman
kareman / Queue.swift
Last active July 31, 2020 19:16
A standard queue (FIFO - First In First Out) implemented in Swift. Supports simultaneous adding and removing, but only one item can be added at a time, and only one item can be removed at a time. Using the "Two-Lock Concurrent Queue Algorithm" from http://www.cs.rochester.edu/research/synchronization/pseudocode/queues.html#tlq, without the locks.
//
// Queue.swift
// NTBSwift
//
// Created by Kåre Morstøl on 11/07/14.
//
// Using the "Two-Lock Concurrent Queue Algorithm" from http://www.cs.rochester.edu/research/synchronization/pseudocode/queues.html#tlq, without the locks.
// should be an inner class of Queue, but inner classes and generics crash the compiler, SourceKit (repeatedly) and occasionally XCode.
# Install dependencies
#
# * checkinstall: package the .deb
# * libpcre3, libpcre3-dev: required for HTTP rewrite module
# * zlib1g zlib1g-dbg zlib1g-dev: required for HTTP gzip module
apt-get install checkinstall libpcre3 libpcre3-dev zlib1g zlib1g-dbg zlib1g-dev && \
mkdir -p ~/sources/ && \
# Compile against OpenSSL to enable NPN
anonymous
anonymous / Eliminate Interlocked CompareExchange for add_ and remove_ methods for Unity3D
Created December 22, 2012 10:45
Replace event add_/remove_ methods with versions that do not use Interlocked.CompareExchange<T>. Instead they use Delegate.Combine/Remove in a way that lacks thread safety. Needed for AOT compilation on Unity3D
// CAUTION: This can irreversibly change your DLLs.
// Reference: Mono.Cecil (DLL version 0.9.4.0, from package Cecil 2.10.9)
using System;
using Mono.Cecil;
using Mono.Cecil.Cil;
using System.Linq;
using System.IO;
using System.Collections.Generic;
@didip
didip / tornado-pypy-env-setup.sh
Created August 1, 2011 21:20
Downloading and Configuring PyPy under virtualenv
#!/bin/bash
#
# Convenience script for downloading and configuring pypy under virtualenv
#
# Dependencies:
# * pip install virtualenv
# Configure these variables to your liking...
project_name="my_tornado_project"
@joelambert
joelambert / README
Created June 1, 2011 11:03
Drop in replacements for setTimeout()/setInterval() that makes use of requestAnimationFrame() where possible for better performance
Drop in replace functions for setTimeout() & setInterval() that
make use of requestAnimationFrame() for performance where available
http://www.joelambert.co.uk
Copyright 2011, Joe Lambert.
Free to use under the MIT license.
http://www.opensource.org/licenses/mit-license.php