Skip to content

Instantly share code, notes, and snippets.


James M. Greene JamesMGreene

View GitHub Profile
JamesMGreene / createCommit.js
Last active Dec 16, 2019
Pseudo-JS code for creating a commit via the GitHub API from a Probot app
View createCommit.js
// Getting tree
const { data: baseTree } = await client.gitdata.getTree({
owner: login,
repo: repo,
tree_sha: sha,
recursive: 1
const baseSha = baseTree.sha
const baseEntriesByPath = baseTree.tree.reduce((entriesByPath, entry) => {
JamesMGreene / genRandomStrings.js
Created Dec 12, 2017
Generic random alphabetical strings with JavaScript
View genRandomStrings.js
var validChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
var validCharsUpperBound = validChars.length - 1;
function randomInt(lower, upper) {
return lower + Math.floor(Math.random() * (upper - lower + 1))
function randomLetter() {
return validChars[randomInt(0, validCharsUpperBound)];
JamesMGreene / gist:ec88338f047db436a1865aae23af83fd
Created Nov 17, 2017 — forked from kitek/gist:1579117
NodeJS create md5 hash from string
View gist:ec88338f047db436a1865aae23af83fd
var data = "do shash'owania";
var crypto = require('crypto');
View app.js
This file has been truncated, but you can view the full file.
FuseBox.pkg("default", {}, function(___scope___){
___scope___.file("index.js", function(exports, require, module, __filename, __dirname){
var zmq = require('zmq')
var pub = zmq.socket('pub')
console.log('Publisher bound to port 3000')
JamesMGreene /
Last active Feb 6, 2018
Trying out nexe@2.x beta native module bundling


  • Windows 10 (x64)
  • VS2015
  • Python 2.7.11
  • node@6.11.0
  • nexe@2.0.0-beta.2
  • fuse-box@2.2.1

Looking for workshop teachers to teach on the following topics!

For introductions please tweet @frontendmasters, @1marc or email: marc at Thanks!

You can propose other topics too.

Published blog post detailing topics and allowed people to vote on priority: 2016 Frontend Masters topic poll

Bolded topics are very highly requested.

JamesMGreene / isXhtmlDoc.js
Last active May 10, 2016
Simple function to determine if a given Document object in JavaScript represents an XHTML document.
View isXhtmlDoc.js
// References important to this particular implementation:
// -
// -
// -
// -
// Other related references if additional parameters are ever needed:
// -
// -
JamesMGreene /
Last active Apr 14, 2016
WebDriver Download URLs and info for all desktop WebDriver instances

General Selenium download info available on [SeleniumHQ][]


Must run the installer:

  • v1.0 a.k.a. "Microsoft WebDriver"
  • v2.0 a.k.a. "Microsoft WebDriver Fall 2015 Update"
JamesMGreene / EventedDatastore.js
Last active Jun 26, 2021
Forcibly adding NeDB events by deriving from the Datastore prototype
View EventedDatastore.js
// As of nedb@^1.7.0, Datastore now inherits from EventEmitter in the NeDB core module.
// If you need to support older versions of NeDB, please look at the following previous revision
// of this gist:
This gist provides a module which derives from the NeDB Datastore module and extends it to
emit several important events:
JamesMGreene / .editorconfig
Created Nov 16, 2015
Example EditorConfig file
View .editorconfig
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
root = true
end_of_line = lf
charset = utf-8