Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jrgm
jrgm / ls-cert-times.js
Created June 15, 2013 03:47
mutate some stdin json
var convertTimes = true;
function handleEmail(obj) {
delete obj.pub;
delete obj.priv;
var cert = obj.cert;
if (cert) {
delete cert.header;
var payload = cert.payload;
if (payload) {
@jrgm
jrgm / parse.pl
Created May 29, 2013 07:35
because...
#!/usr/bin/perl
use strict;
my $requests = {};
sub strip_args {
$_ = $_[0];
s/\?ver=.*/\?ver=/;
s/\?email=.*/\?email=/;
s/\?token=.*/\?token=/;
s/\?domain=.*/\?domain=/;
@jrgm
jrgm / verifier-metrics.js
Last active December 17, 2015 16:49
verifier-metrics.js
// usage: cat file | verifier-metrics.js
const ONE_HOUR_MS = 60*60*1000;
function handleData(data, struct) {
var message, epoch = Date.parse(data.timestamp);
try {
message = JSON.parse(data.message);
} catch(e) {
@jrgm
jrgm / config.json
Created May 21, 2013 20:10
config.json
{
"domains": {
/*
"browserid.org": [
"browserid-org-0520-1279444257.us-east-1.elb.amazonaws.com"
],
"www.browserid.org": [
"browserid-org-0520-1279444257.us-east-1.elb.amazonaws.com"
],
*/
@jrgm
jrgm / make-aws-aliases.js
Last active December 16, 2015 15:29
hack to convert some semi-structured notes into bash aliases for aws, etc.
#!/usr/bin/env node
const fs = require('fs');
const rimraf = require('rimraf'); // XXX remove this dependency
const format = require('util').format;
function createAliases(loadBalancers, targetDirectory) {
var aliases = {};
Object.keys(loadBalancers).forEach(function(key) {
var lb = loadBalancers[key];
@jrgm
jrgm / gist:5303230
Created April 3, 2013 17:19
send a test blob.
#!/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/. */
var client = require('../lib/wsapi_client.js');
var optimist = require('optimist');
var path = require('path');
var urlparse = require('urlparse');
@jrgm
jrgm / gist:5200281
Created March 19, 2013 21:25
force redirect to return full https url on redirect in production.
diff --git a/server/lib/passport_yahoo.js b/server/lib/passport_yahoo.js
index 2b4d7fb..9cac18c 100644
--- a/server/lib/passport_yahoo.js
+++ b/server/lib/passport_yahoo.js
@@ -71,7 +71,15 @@ exports.views = function(app) {
session.clearBidUrl(req);
session.setCurrentUser(req, email);
- res.redirect(redirect_url);
+ if (config.get('env') === 'production') {
@jrgm
jrgm / what-user-agent.js
Last active December 14, 2015 10:58
A test hack that just dumps some info about what userAgent we get on Saucelabs for various {version,browserName,platform}. For checking config changes in mozilla/browserid/automation-tests/config/sauce-platforms.js
#!/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/. */
// This test is only intended for occasional use to confirm the actual browser
// userAgent and OS. Useful in checking changes to sauce-platforms.js.
const
@jrgm
jrgm / issue3030.diff
Last active December 14, 2015 00:58
decouple mozilla/browserid/automation-tests from having to require a full npm install of browserid in the parent directory. (automation-tests usage of lib/wsapi-client.js is simply as a client for saucelabs API). (Update: this won't work long term when we really need api versioning)
diff --git a/lib/wsapi_client.js b/lib/wsapi_client.js
index 3531810..ad9ea09 100644
--- a/lib/wsapi_client.js
+++ b/lib/wsapi_client.js
@@ -13,8 +13,26 @@ const
http = require('http'),
https = require('https'),
url = require('url'),
-querystring = require('querystring'),
-version = require('./version.js');
@jrgm
jrgm / whatis-25f7bcf.js
Last active December 13, 2015 19:49
was it truncated over http?
var fs = require('fs');
var crypto = require('crypto');
var targetSha = '25f7bcf998cc3747cad755d53dec4c6698aad834';
var candidates = {
includeJs_2425cff7: {
filename: 'whatis-25f7bcf.at.2425cff7aeb9c8d4b4b930168d341e3b401a4d89',
knownSha: '7b7d2e96f46271f79a83395ed1486a69c2135d89',
},