Skip to content

Instantly share code, notes, and snippets.

@jrgm
jrgm / sometopo.json
Last active December 18, 2022 12:04
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 =
// 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 January 15, 2016 21:15
check for typos in config file
#!/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 March 15, 2015 06:44
compare json serialization: default toJSON vs. asking for an additional .toString('hex') format
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 August 29, 2015 14:06
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)
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 February 5, 2014 22:18
logging change diff v. rel 10.09
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 August 29, 2015 13:56
fix webdriver tests
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 October 16, 2013 05:23
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');