This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
I needed a button in the Firefox UI to toggle the default page zoom level | |
setting offered by the NoSquint extension (shown as "extensions.nosquint.fullZoomLevel" | |
in about:config). Since this isn't likely to be provided directly and I | |
wasn't interested in writing my own extension for something so simple, I | |
looked for an extension that would expose about:config settings to buttons. | |
Instead, I found the Custom Buttons extension: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require File.expand_path("../init", __FILE__) | |
require 'rack/ssl-enforcer' | |
# Require HTTPS for all requests (not required; remove if unavailable) | |
use Rack::SslEnforcer | |
AUTH_CREDS = { user: 'user', pass: 'password' } | |
# Create a middleware to add HTTP basic auth to all but the whitelisted paths | |
class ProtectedApp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DASH | |
---- | |
Not actually supported by POSIX alone. Googled from http://www.spinics.net/lists/dash/msg00327.html: | |
$ exec 3>&1 # duplicate original stdout | |
$ result=$( | |
exec 4>&1 >&3 3>&- # move cmd subst stdout, and restore original | |
{ ./main.sh; echo $? >&4 # run command, and record its status | |
} | head -n 3) | |
$ echo $result # status from ./main.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Here's a contrived example of a LEFT JOIN using ARel. This is an example of | |
# the mechanics, not a real-world use case. | |
# NOTE: In the gist comments, @ozydingo linked their general-purpose ActiveRecord | |
# extension that works for any named association. That's what I really wanted! | |
# Go use that! Go: https://gist.github.com/ozydingo/70de96ad57ab69003446 | |
# == DEFINITIONS | |
# - A Taxi is a car for hire. A taxi has_many :passengers. | |
# - A Passenger records one person riding in one taxi one time. It belongs_to :taxi. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Adds left joins to ActiveRecord. | |
# | |
# = Description | |
# | |
# This patch adds a #left_joins method to ActiveRecord models and relations. It | |
# works like #joins, but performs a LEFT JOIN instead of an INNER JOIN. | |
# | |
# = A warning about +count+ | |
# | |
# When using with #count, ActiveRecord 3.2.8 is hard-coded to act as if |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Collection of helpers for math-related ARel NamedFunctions. | |
# | |
# Include this in classes that need to do trig with DB functions. Lets you write | |
# cleaner code, like: | |
# | |
# dist = acos(sin(lat) * sin(arel_lat_field) + | |
# cos(lat) * cos(arel_lat_field) * cos(arel_lng_field)) * EARTH_RADIUS_KM | |
# band_num = round(dist / ring_width, 0) | |
# band_num.to_sql | |
# # => round(abs(acos( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using System.Collections.Generic; | |
/* Google Analytics integration. Web page must be configured for GA with Google's javascript snippet. | |
* | |
* Based on a comment from 2010 found here: | |
* http://blog.mostlytigerproof.com/2009/10/06/gathering-statistics-using-google-analytics-and-unity-3d/ | |
* | |
* Analytics category/action/label/value descriptions: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# | |
# haters.rb | |
# | |
# Finds all the Twitter users posted to http://gamerfury.tumblr.com and prints | |
# them, newline-delimited, to STDOUT. Require this file in your own script to | |
# access ScumbagHaterFinder directly. | |
# | |
# Tested with Ruby 2.0.0. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Permission to Leave | |
// @namespace permission.to.leave | |
// @description Prompts before leaving the page. Good for OS X users who press Cmd+Left while editing text to go to the start of the line, only to find the browser goes back a page instead. | |
// @version 1.0 | |
// @grant none | |
// @include http://edit.script.and | |
// @include https://add.target.sites.here | |
// @include https://twitter.com | |
// ==/UserScript== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# rotate_desktop.sh | |
# | |
# Rotates modern Linux desktop screen and input devices to match. Handy for | |
# convertible notebooks. Call this script from panel launchers, keyboard | |
# shortcuts, or touch gesture bindings (xSwipe, touchegg, etc.). | |
# | |
# Using transformation matrix bits taken from: | |
# https://wiki.ubuntu.com/X/InputCoordinateTransformation |
OlderNewer