Skip to content

Instantly share code, notes, and snippets.


David Miranda panphora

Block or report user

Report or block panphora

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View minimal-analytics-snippet.js
(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {
View gist:97c00e3e7826df643c4097f6636b4a14
// <button> reset
// 1. Remove default browser appearance for buttons.
// 2. Remove margins.
// 3. Remove borders for IE.
// 4. Normalize font and color not inherited by `button`.
// 5. Address `overflow` in IE
// 6. Normalize cursor style
egardner / deepequal.js
Created May 22, 2017
Simple deep equality comparison in Javascript (ES5+)
View deepequal.js
// Deep Equality comparison example
// This is an example of how to implement an object-comparison function in
// JavaScript (ES5+). A few points of interest here:
// * You can get an array of all an object's properties in ES5+ by calling
// the class method Object.keys(obj).
// * The function recursively calls itself in the for / in loop when it
// compares the contents of each property
// * You can hide a "private" function inside a function of this kind by
jacurtis / _spacing-helpers.scss
Last active Dec 3, 2019
SASS Margin and Padding Helpers Loop. Generates .m-t-10 type helper classes.
View _spacing-helpers.scss
This .scss loop will create "margin helpers" and "padding helpers" for use in your web projects.
It will generate several classes such as:
.m-r-10 which gives margin-right 10 pixels.
.m-r-15 gives MARGIN to the RIGHT 15 pixels.
.m-t-15 gives MARGIN to the TOP 15 pixels and so on.
.p-b-5 gives PADDING to the BOTTOM of 5 pixels
.p-l-40 gives PADDING to the LEFT of 40 pixels
Daniel-Hug / delegate-event.js
Last active Mar 7, 2019
Vanilla JS equivalent of jQuery's .live(): use event delegation to handle events whose target matches a selector, closest(): get nearest parent element matching selector
View delegate-event.js
// get nearest parent element matching selector
var closest = (function() {
var el = HTMLElement.prototype;
var matches = el.matches || el.webkitMatchesSelector || el.mozMatchesSelector || el.msMatchesSelector;
return function closest(el, selector) {
return, selector) ? el : closest(el.parentElement, selector);
mikberg / connection.js
Last active Jun 18, 2019
MongoDB connection with async/await
View connection.js
import { MongoClient } from 'mongodb';
import promisify from 'es6-promisify';
let _connection;
const connect = () => {
if (!process.env.MONGO_CONNECTION_STRING) {
throw new Error(`Environment variable MONGO_CONNECTION_STRING must be set to use API.`);
View bling.js
/* bling.js */
window.$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
NodeList.prototype.__proto__ = Array.prototype;
youssman / dash-to-camelCase.js
Created Nov 5, 2014
Javascript convert dash (hyphen) to camelcase
View dash-to-camelCase.js
function dashToCamelCase( myStr ) {
return myStr.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase(); });
var myStr = dashToCamelCase( 'this-string' );
alert( myStr ); // => thisString
learncodeacademy /
Last active Nov 18, 2019
Deploy Node.js Apps with Flightplan

##Setup your server (this would ideally be done with automated provisioning)

  • add a deploy user with password-less ssh see this gist
  • install forever npm install -g forever

##Install flightplan

  • npm install -g flightplan
  • in your project folder npm install flightplan --save-dev
  • create a flightplan.js file
staltz /
Last active Dec 7, 2019
The introduction to Reactive Programming you've been missing
You can’t perform that action at this time.