Skip to content

Instantly share code, notes, and snippets.

View hughes's full-sized avatar

Matt Hughes hughes

View GitHub Profile

Keybase proof

I hereby claim:

  • I am hughes on github.
  • I am hughes (https://keybase.io/hughes) on keybase.
  • I have a public key whose fingerprint is 66EF 79CC CD2A 625C A2EA 52D4 2403 FBFA 40B5 2DBF

To claim this, I am signing this object:

@hughes
hughes / gist:9231371
Created February 26, 2014 15:18
Are ghosts undead?
09:47 < ghost[]> ghosts aren't undead!
09:47 < ghost[]> they're just dead
09:50 < Lydia_K> Yeah, I think they are just dead
09:52 < huf> undead doesnt necessarily mean "died and rose again"
09:53 < huf> could mean "life extended beyond natural means by evil trickery" or some shit
09:53 < huf> (the lord of the nazgul was undead, but hadnt died even once (prior to the eowyn fiasco))
do_dlog = true
true
window.navigator.userAgent
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Safari/537.36"
0 1393609938310 "running pw_to_login" sitewide-js.js:30922
0 1393609938311 "about to pw_to_pwh" sitewide-js.js:36881
0 1393609938312 "about to getsalt" sitewide-js.js:36881
192 1393609938504 "done getting salt" sitewide-js.js:36881
0 1393609938505 "about to scrypt_hash_passphrase" sitewide-js.js:36881
99 1393609938604 Object {what: "pbkdf2 (pass 1)", total: 32, i: 0} sitewide-js.js:36881
do_dlog = true
true
0 1393615541391 "running pw_to_login" sitewide-js.js:30922
0 1393615555212 "about to pw_to_pwh" sitewide-js.js:36881
53230 1393615608442 "about to getsalt"
private String makeMessageStr(HashMap<String, String> messageHash) {
String from_number = messageHash.get("from_number");
Uri uri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(from_number));
Cursor people = getContentResolver().query(uri, new String[]{ContactsContract.PhoneLookup.DISPLAY_NAME}, null, null, null);
int indexName = people.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME);
String name = from_number;
if (people.getCount() > 0) {
@hughes
hughes / gist:bfe7afbfe968ce803613
Created May 25, 2014 19:12
angular filters for currency formatting
angular.module("filters", [])
.filter('round', function () {
return function (input, precision) {
return input ? parseFloat(input).toFixed(precision) : "";
};
})
.filter('dollars', function () {
return function (input) {
return input ? '$' + input : ''
};
@hughes
hughes / 0_reuse_code.js
Created July 9, 2014 02:27
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
function reloadCSS() {
var d = (new Date()).getTime();
$('link[rel=stylesheet]').each(function (i, el) {
var href = $(el).attr('href');
if (href.indexOf('?') === -1) {
href += '?_=' + d;
} else {
if (href.indexOf('_=') === -1) {
href += '&_=' + d;
} else {
@hughes
hughes / gist:0c072bf7c9ec23d9f2c7
Created September 2, 2014 19:42
Abandoned laptop email script
#!/bin/bash
idletime=$((1000*60*5)) # 5 minutes in milliseconds
idleMessageSent=0
while true; do
idle=`xprintidle`
if [[ "$idle" -gt "$idletime" ]]; then
if [[ "$idleMessageSent" -eq 0 ]]; then
if (gnome-screensaver-command -q | grep "is active"); then
@hughes
hughes / gist:2e8eda0cf05687ce95f1
Created September 16, 2014 14:44
Unicode variable names...
var R = 6371; // km
var φ1 = lat1.toRadians();
var φ2 = lat2.toRadians();
var Δφ = (lat2-lat1).toRadians();
var Δλ = (lon2-lon1).toRadians();
var a = Math.sin(Δφ/2) * Math.sin(Δφ/2) +
Math.cos(φ1) * Math.cos(φ2) *
Math.sin(Δλ/2) * Math.sin(Δλ/2);
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));