Skip to content

Instantly share code, notes, and snippets.

View gist:f830c768a2774e638a575192c74d10b4
diff --git a/emailserver.js b/emailserver.js
index e40f738..9a063c2 100755
--- a/emailserver.js
+++ b/emailserver.js
@@ -24,6 +24,32 @@ function logError(err) {
log("ERROR (oh noes!): " + err);
}
+function mailSummary(mail) {
+ const deliveryTime =
View prime.js
// returns all the prime factors of a positive integer
function prime_factors(n) {
var factors = [];
var div = 2;
while (n > 1) {
while (n % div == 0) {
factors.push(div);
n /= div;
}
div++;
@jrgm
jrgm / check-oauth-yaml.js
Created Jan 15, 2016
check for typos in config file
View check-oauth-yaml.js
#!/usr/bin/env node
// Run this script after editing ./fxa/yaml/type/fxa.fxa_oauth.prod.yaml or
// ./fxa/yaml/type/fxa.fxa_oauth.stage.yaml and fix any typos before
// committing changes.
var assert = require('assert')
var fs = require('fs')
var yaml
@jrgm
jrgm / benchmark.js
Created Mar 15, 2015
compare json serialization: default toJSON vs. asking for an additional .toString('hex') format
View benchmark.js
var Benchmark = require('benchmark');
var suite = new Benchmark.Suite;
var obj1 = { food: Buffer('c0ffee', 'hex'), bar: 3 };
var obj2 = {
'id': Buffer('eceb3ae8aee125e2', 'hex'),
'secret': Buffer('281a885146ee216844d1ffd0d725ee714101548a1e6507f1a40fb2c2ae0c11f1', 'hex'),
'name':'blah',
@jrgm
jrgm / memcached-dump.js
Last active Aug 29, 2015
memcached-dump.js
View memcached-dump.js
var P = require('bluebird')
var util = require('util')
var memcached = require('memcached')
var underscore = require('underscore')
function getItems(mc) {
var dfd = P.defer()
mc.items(function(err, result) {
if (err) return dfd.reject(err)
dfd.resolve(result)
View gist:9824193
use strict;
use POSIX qw(strftime);
my $slots = {};
# 1395889976.092 10.178.6.136 "GET / HTTP/1.1" 200 71 "-" "ELB-HealthChecker/1.0" "-" 0.002
# 1395962183.009 10.178.6.136 "POST /v1/certificate/sign HTTP/1.1" 200 822 "-" "python-requests/2.2.1 CPython/2.7.3 Linux/3.5.0-23-generic" "54.218.210.15" 0.458
while (<STDIN>) {
next unless m@certificate/sign@;
@jrgm
jrgm / logging.diff
Created Feb 5, 2014
logging change diff v. rel 10.09
View logging.diff
diff --git a/lib/configuration.js b/lib/configuration.js
index 5736fde..8456373 100644
--- a/lib/configuration.js
+++ b/lib/configuration.js
@@ -294,7 +294,17 @@ var conf = module.exports = convict({
forcible_issuers: {
doc: "Hostnames which this Persona instance will issue identies for. Used in b2g only.",
format: 'array { string }* = [ "fxos.login.persona.org"]',
- }
+ },
@jrgm
jrgm / tests.diff
Last active Aug 29, 2015
fix webdriver tests
View tests.diff
diff --git a/automation-tests/tests/remove-email.js b/automation-tests/tests/remove-email.js
index 8e7e0de..16defd1 100644
--- a/automation-tests/tests/remove-email.js
+++ b/automation-tests/tests/remove-email.js
@@ -140,6 +140,8 @@ runner.run(module, {
browser.chain({onError: done})
.wwin()
.get(link)
+ .wtype(CSS['persona.org'].signInForm.password, secondaryPassword)
+ .wclick(CSS['persona.org'].signInForm.finishButton, secondaryPassword)
@jrgm
jrgm / hook-process-stderr-write.js
Created Oct 16, 2013
hook-process-stderr-write.js
View hook-process-stderr-write.js
process.stderr.write = (function(writer) {
return function(string, encoding, fd) {
writer.call(process.stderr, 'hooked => ');
writer.apply(process.stderr, arguments);
}
})(process.stderr.write);
process.stderr.write('foo\n');
console.error('bar');
console.log('baz');
@jrgm
jrgm / ls-cert-times.js
Created Jun 15, 2013
mutate some stdin json
View ls-cert-times.js
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) {