Skip to content

Instantly share code, notes, and snippets.

View JamesMGreene's full-sized avatar

James M. Greene JamesMGreene

View GitHub Profile
@JamesMGreene
JamesMGreene / createCommit.js
Last active December 16, 2019 20:35
Pseudo-JS code for creating a commit via the GitHub API from a Probot app
// 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
JamesMGreene / genRandomStrings.js
Created December 12, 2017 17:44
Generic random alphabetical strings with JavaScript
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
JamesMGreene / gist:ec88338f047db436a1865aae23af83fd
Created November 17, 2017 15:02 — forked from kitek/gist:1579117
NodeJS create md5 hash from string
var data = "do shash'owania";
var crypto = require('crypto');
crypto.createHash('md5').update(data).digest("hex");
This file has been truncated, but you can view the full file.
(function(FuseBox){FuseBox.$fuse$=FuseBox;
FuseBox.pkg("default", {}, function(___scope___){
___scope___.file("index.js", function(exports, require, module, __filename, __dirname){
var zmq = require('zmq')
var pub = zmq.socket('pub')
pub.bindSync('tcp://127.0.0.1:3000')
console.log('Publisher bound to port 3000')
@JamesMGreene
JamesMGreene / README.md
Last active February 6, 2018 05:06
Trying out [email protected] beta native module bundling
@JamesMGreene
JamesMGreene / teachers-needed.md
Created March 9, 2017 17:18 — forked from 1Marc/workshops-planning.md
Workshop Teachers Needed

Looking for workshop teachers to teach on the following topics!

For introductions please tweet @frontendmasters, @1marc or email: marc at FrontendMasters.com. 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
JamesMGreene / isXhtmlDoc.js
Last active May 10, 2016 17:43
Simple function to determine if a given Document object in JavaScript represents an XHTML document.
//
// References important to this particular implementation:
// - http://ejohn.org/blog/nodename-case-sensitivity/
// - http://help.dottoro.com/ljdgsrle.php
// - http://www.w3schools.com/html/html_xhtml.asp
// - http://www.w3schools.com/tags/tag_doctype.asp
//
// Other related references if additional parameters are ever needed:
// - http://reference.sitepoint.com/javascript/Document/doctype
// - http://reference.sitepoint.com/javascript/DocumentType
@JamesMGreene
JamesMGreene / WebDriverUrls.md
Last active April 14, 2016 11:56
WebDriver Download URLs and info for all desktop WebDriver instances

General Selenium download info available on [SeleniumHQ][]

Edge

Must run the installer:

  • v1.0 a.k.a. "Microsoft WebDriver"
  • v2.0 a.k.a. "Microsoft WebDriver Fall 2015 Update"
@JamesMGreene
JamesMGreene / EventedDatastore.js
Last active June 26, 2021 09:57
Forcibly adding NeDB events by deriving from the Datastore prototype
// IMPORTANT:
// 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:
// https://gist.github.com/JamesMGreene/0e0b2506c7bd2a2557f7/d8b4b1e97bb0d118c509672e3c7276b6dc4ba13a
/*
This gist provides a module which derives from the NeDB Datastore module and extends it to
emit several important events:
@JamesMGreene
JamesMGreene / .editorconfig
Created November 16, 2015 12:04
Example EditorConfig file
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org
root = true
[*]
end_of_line = lf
charset = utf-8