Skip to content

Instantly share code, notes, and snippets.

View mikemaccana's full-sized avatar

Mike MacCana mikemaccana

View GitHub Profile
@mikemaccana
mikemaccana / gist:4170134
Created November 29, 2012 16:24
jshint on current production JQuery UI from front page of website (despite filename its just the production version).
: jshint Downloads/jquery-ui-1.9.2.custom\ 2/js/jquery-ui-1.9.2.custom.js
Downloads/jquery-ui-1.9.2.custom 2/js/jquery-ui-1.9.2.custom.js: line 186, col 9, Expected an assignment or function call and instead saw an expression.
Downloads/jquery-ui-1.9.2.custom 2/js/jquery-ui-1.9.2.custom.js: line 358, col 46, Use '!==' to compare with 'null'.
Downloads/jquery-ui-1.9.2.custom 2/js/jquery-ui-1.9.2.custom.js: line 918, col 52, Expected an assignment or function call and instead saw an expression.
Downloads/jquery-ui-1.9.2.custom 2/js/jquery-ui-1.9.2.custom.js: line 970, col 24, Confusing use of '!'.
Downloads/jquery-ui-1.9.2.custom 2/js/jquery-ui-1.9.2.custom.js: line 982, col 80, Expected an assignment or function call and instead saw an expression.
Downloads/jquery-ui-1.9.2.custom 2/js/jquery-ui-1.9.2.custom.js: line 1581, col 82, Use '===' to compare with 'null'.
Downloads/jquery-ui-1.9.2.custom 2/js/jquery-ui-1.9.2.custom.js: line 2621, col 23, Use '!==' to compare with 'null'.
Downloads/jquery-ui-1.9.2.cust
#!/bin/bash
# herein we backup our indexes! this script should run at like 6pm or something, after logstash
# rotates to a new ES index and theres no new data coming in to the old one. we grab metadatas,
# compress the data files, create a restore script, and push it all up to S3.
TODAY=`date +"%Y.%m.%d"`
INDEXNAME="logstash-$TODAY" # this had better match the index name in ES
INDEXDIR="/usr/local/elasticsearch/data/logstash/nodes/0/indices/"
BACKUPCMD="/usr/local/backupTools/s3cmd --config=/usr/local/backupTools/s3cfg put"
BACKUPDIR="/mnt/es-backups/"
YEARMONTH=`date +"%Y-%m"`
@mikemaccana
mikemaccana / gist:5531683
Created May 7, 2013 10:25
Vanilla JS: select an option in a select box by value
// Required for 7000+ option select box used in EC2 UI that has no search
NodeList.prototype.forEach = Array.prototype.forEach
var requiredValue = 'snap-d1d0a88a'
var selectBox = document.querySelector('select')
selectBox.childNodes.forEach(function(element, index){
if ( element.value === requiredValue ) {
console.log('Found! Index is ', index)
selectBox.selectedIndex = index
}
@mikemaccana
mikemaccana / gist:6094826
Created July 27, 2013 13:09
Simple inheritance with Object.create() and a factory function
var makeObject = function(prototype, properties) {
var newObject = Object.create(prototype || null) // If no prototype is set, just create a regular object literal (which inherits from null)
for ( var property in properties ) {
if ( properties.hasOwnProperty(property) ) {
newObject[property] = properties[property]
}
}
return newObject
}
@mikemaccana
mikemaccana / gist:10847077
Created April 16, 2014 10:13
Tptacek's Review of "Practical Cryptography With Go"

Wow. I've now read the whole book and much of the supporting code. I'm not a fan, and recommend against relying on it. Here's a laundry list of concerns:

  • The teaching method the book uses is badly flawed. The book's strategy is to start simple and build to complexity, which makes sense if you're teaching algebra but not if you're teaching heart surgery. The result is that each chapter culminates with the implementation of a system that is grievously insecure. Little warning is given of this, apart from allusions to future chapters improving the system. For instance, Chapter 2 closes with a chat system that uses AES-CBC without an authenticator.

  • The book is full of idiosyncratic recommendations. For instance, AES-CBC requires a padding scheme. There is a standard padding scheme. The book purports to present it, but instead of PKCS7, it presents 80h+00h..00h.

  • At one point about 1/3rd of the way through the book, it suggests using a SHA256 hash of the plaintext as an authenticator for a message. Thi

@mikemaccana
mikemaccana / gist:fe5c1a83bcbdc0157534
Created February 5, 2015 14:14
Make a sublime-project file that shows only private modules under 'node_modules'
#!/usr/bin/env node
var log = console.log.bind(console);
var fs = require('fs'),
path = require('path'),
jsonFile = require('jsonfile')
require('es6-shim');
var moduleDirs = fs.readdirSync('node_modules').filter(function (file) {
return fs.statSync(path.join('node_modules', file)).isDirectory();
@mikemaccana
mikemaccana / gist:5e12d4d2b8dcfc87b197
Created May 8, 2015 18:28
SSL labs, Moz Server Side TLS 'intermediate' setting, no warnings in Chrome
Just wanted to make sure the IE8 issue isn't a user error:
Android 2.3.7 No SNI 2 Protocol or cipher suite mismatch Fail3
Android 4.0.4 TLS 1.0 TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA (0xc013) FS 128
Android 4.1.1 TLS 1.0 TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA (0xc013) FS 128
Android 4.2.2 TLS 1.0 TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA (0xc013) FS 128
Android 4.3 TLS 1.0 TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA (0xc013) FS 128
Android 4.4.2 TLS 1.2 TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (0xc02f) FS 128
Android 5.0.0 TLS 1.2 TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (0xc02f) FS 128
Baidu Jan 2015 TLS 1.0 TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA (0xc013) FS 128
@mikemaccana
mikemaccana / gist:67b94d06bbdf01c94fa4
Created May 8, 2015 18:46
Simply add GCM ciphers to top of existing list
Handshake Simulation
Android 2.3.7 No SNI 2 TLS 1.0 TLS_RSA_WITH_AES_128_CBC_SHA (0x2f) No FS 128
Android 4.0.4 TLS 1.0 TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA (0xc014) FS 256
Android 4.1.1 TLS 1.0 TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA (0xc014) FS 256
Android 4.2.2 TLS 1.0 TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA (0xc014) FS 256
Android 4.3 TLS 1.0 TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA (0xc014) FS 256
Android 4.4.2 TLS 1.2 TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (0xc02f) FS 128
Android 5.0.0 TLS 1.2 TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (0xc02f) FS 128
Baidu Jan 2015 TLS 1.0 TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA (0xc014) FS 256
@mikemaccana
mikemaccana / gist:38ecc4a4f9374144106d
Last active August 29, 2015 14:20
Updated test, after removing kEDH+AESGCM
Handshake Simulation
Android 2.3.7 No SNI 2 TLS 1.0 TLS_RSA_WITH_AES_128_CBC_SHA (0x2f) No FS 128
Android 4.0.4 TLS 1.0 TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA (0xc014) FS 256
Android 4.1.1 TLS 1.0 TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA (0xc014) FS 256
Android 4.2.2 TLS 1.0 TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA (0xc014) FS 256
Android 4.3 TLS 1.0 TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA (0xc014) FS 256
Android 4.4.2 TLS 1.2 TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (0xc02f) FS 128
Android 5.0.0 TLS 1.2 TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (0xc02f) FS 128
Baidu Jan 2015 TLS 1.0 TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA (0xc014) FS 256
BingPreview Jan 2015 TLS 1.2 TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (0xc02f) FS 128
Handshake Simulation
Android 2.3.7 No SNI 2 TLS 1.0 TLS_RSA_WITH_AES_128_CBC_SHA (0x2f) No FS 128
Android 4.0.4 TLS 1.0 TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA (0xc014) FS 256
Android 4.1.1 TLS 1.0 TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA (0xc014) FS 256
Android 4.2.2 TLS 1.0 TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA (0xc014) FS 256
Android 4.3 TLS 1.0 TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA (0xc014) FS 256
Android 4.4.2 TLS 1.2 TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (0xc02f) FS 128
Android 5.0.0 TLS 1.2 TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (0xc02f) FS 128
Baidu Jan 2015 TLS 1.0 TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA (0xc014) FS 256