Skip to content

Instantly share code, notes, and snippets.


James M. Greene JamesMGreene

View GitHub Profile
JamesMGreene /
Last active May 14, 2021
A comparison of using `git flow` commands versus raw `git` commands.


gitflow git
git flow init git init
  git commit --allow-empty -m "Initial commit"
  git checkout -b develop master

Connect to the remote repository

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
JamesMGreene /
Last active Feb 15, 2021
NPM/semver versioning dilemma

NPM Versioning Dilemma

Background on my Node module

  • I have an existing published Node module, flex-sdk, which basically serves as a downloader and wrapper for an external, non-JavaScript dependency: the Adobe/Apache Flex SDK.
  • As such, the Node module's version number is based on the version of the Flex SDK which it wraps, e.g. flex-sdk@4.5.1 == Flex SDK 4.5.1
  • I just discovered that I should also be bundling additional Flash API libraries (for compilation) with these various SDKs.

The Problem

JamesMGreene / ZeroClipboard "Core" v2
Last active Jun 3, 2020
ZeroClipboard "Core" v2.0.0 API
View ZeroClipboard "Core" v2

ZeroClipboard v2.0.0 "Core" API Draft

Working draft of the API for the new ZeroClipboard "Core" sub-module in v2.0.0. This sub-module only provides the core Flash and clipboard injection facilities but none of the DOM, "Client", resizing, repositioning, etc. logic/code.

NOTE: A checked checkbox means that line item has already been implemented in the latest ZeroClipboard master branch.


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 / clipboard.js
Last active Nov 5, 2019
HTML Clipboard API clarification example
View clipboard.js
var btn = document.getElementById("copy-button");
btn.addEventListener("click", clickHandler, false);
btn.addEventListener("copy", copyHandler, false);
function clickHandler(e) { ClipboardEvent("copy"));
function copyHandler(e) {
e.clipboardData.setData("text/plain", "Simulated copy. Yay!");
JamesMGreene / EventedDatastore.js
Last active Jul 9, 2019
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:
View clipboard.js
var btn = document.getElementById("copy-button");
btn.addEventListener("click", clickHandler, false);
function clickHandler(e) {
var clip = new ClipboardEvent("copy");
clip.clipboardData.setData("text/plain", "foo");
clip.clipboardData.setData("text/html", "<b>foo</b>");
// CRITICAL: Must call `preventDefault();` to get this data into the system/desktop clipboard!!!
JamesMGreene / example_def.rb
Last active Sep 15, 2018
Ruby class methods vs. instance methods
View example_def.rb
class Human
# Class method (a.k.a. static method)
def self.classification
# Instance constructor
def initialize(first_name, last_name)
JamesMGreene / phantomjs-xhr.js
Last active Jun 11, 2018
Example of (a) successfully executing a cross-domain XHR from the PhantomJS outer context to a wildcard CORS-enabled site; and (b) failing to execute a cross-domain XHR from the PhantomJS outer context to a site that is not CORS-enabled.
View phantomjs-xhr.js
var urls = [
/* Wildcard CORS enabled - Works in PhantomJS 1.9.0 */
/* CORS disabled - Fails in PhantomJS 1.9.0 (and every other version) */
/* Hack workaround? */
function(httpGet, callback) { = ( || {}); = false;