Skip to content

Instantly share code, notes, and snippets.

Avatar

James M. Greene JamesMGreene

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

Initialize

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
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
# editorconfig.org
root = true
[*]
end_of_line = lf
charset = utf-8
@JamesMGreene
JamesMGreene / npmVersionDilemma.md
Last active Feb 15, 2021
NPM/semver versioning dilemma
View npmVersionDilemma.md

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
JamesMGreene / ZeroClipboard "Core" v2 API.md
Last active Jun 3, 2020
ZeroClipboard "Core" v2.0.0 API
View ZeroClipboard "Core" v2 API.md

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.

API

@JamesMGreene
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
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) {
e.target.dispatchEvent(new ClipboardEvent("copy"));
}
function copyHandler(e) {
e.clipboardData.setData("text/plain", "Simulated copy. Yay!");
@JamesMGreene
JamesMGreene / EventedDatastore.js
Last active Jul 9, 2019
Forcibly adding NeDB events by deriving from the Datastore prototype
View EventedDatastore.js
// 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:
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!!!
clip.preventDefault();
@JamesMGreene
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
'Mammal'
end
# Instance constructor
def initialize(first_name, last_name)
@JamesMGreene
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 */
'http://updates.html5rocks.com',
/* CORS disabled - Fails in PhantomJS 1.9.0 (and every other version) */
'http://www.google.com',
/* Hack workaround? */
/*
function(httpGet, callback) {
phantom.page.settings = (phantom.page.settings || {});
phantom.page.settings.webSecurityEnabled = false;