Skip to content

Instantly share code, notes, and snippets.

@jrgm
jrgm / verifier.diff
Created February 13, 2013 04:18
Use app.error to return JSON.parse snafus as '400 Bad Request'
diff --git a/bin/verifier b/bin/verifier
index 1c108fd..d04c6d2 100755
--- a/bin/verifier
+++ b/bin/verifier
@@ -61,6 +61,24 @@ if (statsd_config && statsd_config.enabled) {
app.use(express.bodyParser());
+app.error(function(err, req, resp, next) {
+ if (!err) return next();
@jrgm
jrgm / start-ff.sh
Created February 11, 2013 21:50
start Firefox with disposable profiles on osx
#!/bin/sh
# start Firefox with disposable profiles on osx
# usage: start-ff.sh profilename Firefox.app
# start-ff.sh profilename Aurora.app
# start-ff.sh profilename Nightly.app
PROFILE_NAME=abcabdab-sync1
if [ ! -z "$1" ]; then
PROFILE_NAME=$1
@jrgm
jrgm / grabsocket.pl
Created January 31, 2013 07:16
grab sockets using specific range of local ports all at once; how many in range are available (wait a couple of minutes before checking again on the same range, because obviously that range will be in time_wait).
use strict;
use IO::Socket::INET;
sub socketConnect {
my ($localPort) = @_;
my $err;
my $sock = IO::Socket::INET
->new(PeerAddr => '127.0.0.1',
PeerPort => '63300',
@jrgm
jrgm / sc.js
Created January 31, 2013 06:57
Measure time and responses
// Measure time and responses
// usage: while [ 1 ]; do node sc.js; sleep 5; done
// or: while [ 1 ]; do SC_HEARTBEAT=1 node sc.js; sleep 5; done
var http = require('http');
var path, heartbeat;
if (process.env.SC_HEARTBEAT) {
heartbeat = true;
path = '/__heartbeat__';
@jrgm
jrgm / grab-a-socket.js
Last active December 11, 2015 22:39
Exercise the local ephemeral port range and see if it's exhausted
// Exercise the local ephemeral port range and see if it's exhausted
// usage: `while [ 1 ]; do node ~/grab-a-socket.js; sleep 1; done`
var net = require('net');
var options = {
port: 63300,
host: '127.0.0.1'
};
@jrgm
jrgm / parse-ss.js
Last active December 11, 2015 22:39
Count the tcp socket states from `ss(8)`
// Count the tcp socket states from `ss(8)`
// usage: `while [ 1 ]; do ss -tanp | node ~/parse-ss-localports.js; sleep 5; done`
var _ = require('underscore');
var FIELDS = { STATE: 0, RECVQ: 1, SENDQ: 2, LOCAL: 3, REMOTE: 4 };
function uniqueEphemeral(list) {
return _.uniq(list).filter(isEphemeral).length;
}
@jrgm
jrgm / gist:4490664
Last active December 10, 2015 20:48
Stupid hack to track response times with b2g requests when NSPR_LOG_MODULES is enabled in this way.
use strict;
$| = 1;
# Stupid hack to track response times with b2g requests.
# You need to set 'export NSPR_LOG_MODULES=timestamp,cookie:5,nsSocketTransport:5,nsHttp:5'
# in /system/bin/b2g.sh. See https://gist.github.com/4490638 (but probably will
# want to remove the busybox section, installed from /home/jrgm ;-) ).
#
# usage: `adb logcat | tee /tmp/raw.txt | perl thisfile.pl`
@jrgm
jrgm / gist:4490638
Last active December 10, 2015 20:48
enable NSPR HTTP logging for b2g phones...
#!/bin/sh
# You may of course prefer not to trust this script and do the below
# manually, step by step, with an editor, etc., ;-).
#
# make /system/bin writable
#
DISK_DEVICE=`adb shell mount | grep '/system' | awk '{ print $1 }'`
adb shell "mount -o remount,rw $DISK_DEVICE /system"
@jrgm
jrgm / awsnap.js
Created November 13, 2012 23:41
If you visit login.dev.persona.org first, there is no Aw, snap!
#!/usr/bin/env node
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//
// Two switches to control how this runs:
// 1) VISIT_PERSONA=1 - Load the login.dev.anosrep.org first
@jrgm
jrgm / check-persona-url.py
Created August 22, 2012 05:48
enumerate possible urls
#!/usr/bin/env python
import json
import os
import requests
# https://bugzilla.mozilla.org/show_bug.cgi?id=781838
# - POSTs MUST never redirect
# - POST over non-SSL MUST fail 400 Bad Non-SSL
# - GETs to the old domains MUST redirect to the new domain
# - www. MUST always redirect