Skip to content

Instantly share code, notes, and snippets.

View pdehaan's full-sized avatar
🏠
Working from home

Peter deHaan pdehaan

🏠
Working from home
View GitHub Profile
@pdehaan
pdehaan / index.js
Created April 11, 2014 02:35
Scan your Firefox bookmarks exported JSON for HTTPS bookmarks succeptable to heartbleed exploit
var fs = require("fs");
var url = require("url");
var heartbleed = require("heartbleed");
var jsonselect = require("jsonselect");
var Promise = require("promise");
var readFile = Promise.denodeify(fs.readFile);
readFile("bookmarks.json", "utf8").then(JSON.parse).then(function (data) {
function loadPage(address, route, lang){
page.customHeaders = {'accept-language': lang};
var address = url + route;
var docLocator;
var fxaHeader;
if (page === 'signup'){
docLocator = 'sign-up';
fxaHeader = "fxa-signup-header";
}else if(page === 'signin'){
@pdehaan
pdehaan / index.js
Created February 13, 2015 02:04
Grab public user Gists using JavaScript
'use strict';
var GitHubApi = require('github');
var github = new GitHubApi({
version: "3.0.0"
});
github.gists.getFromUser({
user: 'pdehaan',
{
"name": "Push Testing",
"strategies": [
{
"name": "Single Serverz",
"description": "Single PushGo server, 2 sets of testers for peak of 200k connections.",
"container_sets": [
{
"name": "Test Cluster",
"instance_count": 1,
@pdehaan
pdehaan / gist_create.js
Created March 10, 2015 17:13
Creates an anonymous, secret Gist.
'use strict';
var fs = require('fs');
var github = require('octonode');
var client = github.client();
var gist = client.gist();
gist.create({
description: 'gist description',
files: {
@pdehaan
pdehaan / index.js
Created May 14, 2015 06:04
restmail+fetch example
var fetch = require('node-fetch')
fetch.Promise = require('promise')
getEmails('testfetch@restmail.net')
// Filter only FxA emails and only return the x-link header.
.then((messages) => messages.filter(filterFunc).map(getLink))
.then(console.log)
.catch(console.error)
function getEmails (account) {
@pdehaan
pdehaan / index.js
Created May 14, 2015 22:27
Node+ngrok example
var ngrok = require('ngrok')
var PORT = process.env.PORT || 8080
ngrok.connect(PORT, function (err, url) {
if (err) {
return console.error(err)
}
console.log('success: %s', url)
})
@pdehaan
pdehaan / manifest.groovy
Created June 20, 2015 00:36
Grab a JSON manifest from a remote GitHub URL
import groovy.json.JsonSlurper
Map getJson(String project) {
String repoUrl = "https://raw.githubusercontent.com/mozilla-services/services-test/master/e2e/${project}/package.json".toString()
JsonSlurper jsonSlurper = new JsonSlurper()
return jsonSlurper.parse(repoUrl.toURL())
}
Map datum = getJson('pocket')
println datum.name + '@' + datum.version
@pdehaan
pdehaan / l10n-json-to-html.js
Created July 10, 2015 14:54
Convert l10n .json files to .html
module.exports = function (grunt) {
grunt.registerMultiTask('l10n-json-to-html', 'Convert l10n JSON files to HTML', function () {
var done = this.async();
var yeoman = grunt.config('yeoman');
var fileCount = 0;
this.files.forEach(function (file) {
var src = file.src[0];
// Convert source file to something like '.tmp/i18n/{locale}/{file}.html'.
var dst = src.replace(yeoman.dist, yeoman.tmp).replace(/\.json$/i, '.html');
@pdehaan
pdehaan / idea-town-gulpfile.js
Created August 6, 2015 06:55
async tasks in mozilla/idea-town gulpfile.js
var gulp = require('gulp'),
autoprefixer = require('gulp-autoprefixer'),
cache = require('gulp-cache'),
committers = require('gulp-git-committers'),
concat = require('gulp-concat'),
data = require('gulp-data'),
del = require('del'),
eslint = require('gulp-eslint'),
imagemin = require('gulp-imagemin'),
jade = require('gulp-jade'),