Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

David Miranda panphora

🎯
Focusing
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 jquery.addrule.js
/*!
* jquery.addrule.js 0.0.2 - https://gist.github.com/yckart/5563717/
* Add css-rules to an existing stylesheet.
*
* @see http://stackoverflow.com/a/16507264/1250044
*
* Copyright (c) 2013 Yannick Albert (http://yckart.com)
* Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php).
* 2013/11/23
**/
@staltz
staltz / introrx.md
Last active Oct 18, 2019
The introduction to Reactive Programming you've been missing
View introrx.md
@learncodeacademy
learncodeacademy / flightplan-deploy.md
Last active Oct 10, 2019
Deploy Node.js Apps with Flightplan
View flightplan-deploy.md

##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
@youssman
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
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;
@mikberg
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.`);
}
@Daniel-Hug
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 matches.call(el, selector) ? el : closest(el.parentElement, selector);
};
})();
@jacurtis
jacurtis / _spacing-helpers.scss
Last active Oct 15, 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
@egardner
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
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
You can’t perform that action at this time.