Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title></title>
<script src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
$(document).ready(function(){
$('span').click(function(){
@slant
slant / bluetooth.sh
Created September 20, 2016 22:42
Improving bluetooth audio quality on OS X (both incoming and outgoing)
defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Max (editable)" 80;
defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" 43;
defaults write com.apple.BluetoothAudioAgent "Apple Initial Bitpool (editable)" 80;
defaults write com.apple.BluetoothAudioAgent "Apple Initial Bitpool Min (editable)" 43;
defaults write com.apple.BluetoothAudioAgent "Negotiated Bitpool" 80;
defaults write com.apple.BluetoothAudioAgent "Negotiated Bitpool Max" 80;
defaults write com.apple.BluetoothAudioAgent "Negotiated Bitpool Min" 43;
@slant
slant / redate.sh
Last active August 26, 2016 06:49
Redate image files with original exif data
# Set the date of picture files to the EXIF date
function redate () {
# Replace spaces in filenames with underscores
echo "Removing spaces..."
for file in *; do mv "$file" `echo $file | tr ' ' '_'` ; done
# Get orginal date from EXIF data and update file's metadata dates
# Required: http://www.sno.phy.queensu.ca/~phil/exiftool/
echo "Redating..."
find -E . -type f -iregex '.*\.(jpg|nef)' | while read PIC; do
@slant
slant / thing.rb
Created January 6, 2014 19:46
Experimenting with metaprogramming in Ruby.
class Thing
def self.format_answer_for(question_title, &block)
define_method("__format_answer_for_#{question_title}", &block)
end
end
#################
## Test Case 1 ##
#################
<!doctype html>
<html>
<head>
<style type="text/css">
body, html {
font-family: helvetica;
}
p:before {
@slant
slant / hue.rb
Last active December 28, 2015 20:29
Do random things to a set of Philips Hue bulbs.
require 'rubygems'
require 'hue'
class Data
class << self
def random_state
{ bri: self.random_bri, hue: self.random_hue, sat: self.random_sat }
end
def random_bri
@slant
slant / fb.js
Last active December 19, 2015 02:08
Bookmarklet to auto-accept Facebook group requests.
javascript:var buttons=document.getElementsByClassName('uiButtonText');var add_buttons=new Array;for(var b=0;b<buttons.length;b++){if(buttons[b].innerText=='Add'){add_buttons.push(buttons[b])}};for(var b=0;b<add_buttons.length;b++){add_buttons[b].click()};
@slant
slant / helper.rb
Last active December 17, 2015 08:29
Dynamic route generation in Rails
# Without the extra stuff
# Helper
class Helper
def edit_resource_link(text, resource, &block)
#if CanCan blah blah
content_tag(:a, text, send(:"edit_#{resource.class.name.downcase}_path", resource), &block)
#end
end
end
body {
white-space: pre;
font-family: monospace;
background: #1D1D1D;
color: #FFFFFF
}
body li, body div {
border: 1px solid transparent;
}
@slant
slant / application_controller.rb
Created January 11, 2013 22:52
Best code EVAR!
def state_from_lat_lng(from_lat, from_lng)
State.where(:abbreviation => "TX")
end