Skip to content

Instantly share code, notes, and snippets.

View spiralx's full-sized avatar

James Skinner spiralx

View GitHub Profile
@spiralx
spiralx / select.js
Created February 21, 2018 18:38 — forked from Raynos/select.js
tiny select. Selecting has never been so awesome \o/
// Pretty fast - http://jsperf.com/select-vs-natives-vs-jquery
/*
By, shortcuts for getting elements.
*/
var By = {
id: function (id) { return document.getElementById(id) },
tag: function (tag, context) {
return (context || document).getElementsByTagName(tag)
},
"class": function (klass, context) {
@spiralx
spiralx / postgres-import-db.sh
Created February 3, 2017 11:01 — forked from rponte/postgres-import-db.sh
Drop, create and import database (PostgreSQL)
#export PATH=$PATH:/Library/PostgreSQL/8.4/bin/
dropdb -U postgres mydb
createdb -E UTF8 -U postgres mydb
psql -U postgres -d mydb < mydb-snapshot.sql
# or pg_restore -U postgres --dbname mydb --verbose mydb-snapshot.backup
# or pg_restore -U postgres --dbname mydb --verbose --no-owner mydb-snapshot.backup
@spiralx
spiralx / profile.js
Created January 5, 2017 15:33 — forked from tj/profile.js
nshell profile
/**
* Module dependencies.
*/
var path = require('path')
// prompt
exports.PS1 = function(){
@spiralx
spiralx / globals.snippets.js
Created August 12, 2016 10:30 — forked from pocotan001/globals.snippets.js
Finding improper JavaScript globals.
// globals.js
// https://gist.github.com/pocotan001/6305714
// Finding improper JavaScript globals
(function() {
var prop, cleanWindow,
globals = new function globals() {},
body = document.body,
iframe = document.createElement('iframe'),
ignore = {
@spiralx
spiralx / mocha-guide-to-testing.js
Last active August 11, 2016 13:43 — forked from samwize/mocha-guide-to-testing.js
Explain Mocha's testing framework - describe/it/before/beforeEach etc.
/* -----------------------------------------------------------------------------
### Mocha Guide to Testing ###
Objective is to explain `describe()`, `it()`, and `before()`/etc hooks.
1. `describe()` is merely for grouping, which you can nest as deep
as is required.
2. `it()` is a test case.
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {
// no easing, no acceleration
linear: function (t) { return t },
// accelerating from zero velocity
easeInQuad: function (t) { return t*t },
// decelerating to zero velocity
@spiralx
spiralx / 8-sass-mixins.md
Last active October 17, 2017 13:16 — forked from williamdodson/8-sass-mixins.md
Sass mixins you must have in your toolbox
@spiralx
spiralx / README.md
Created October 12, 2015 11:31 — forked from johan/README.md
JS debug breakpoint / log snippets

stopBefore.js

2min screencast

These tools inject a breakpoint, console.log or console.count in any function you want to spy on via stopBefore('Element.prototype.removeChild') or ditto stopAfter, logBefore / logAfter / logAround / logCount.

Works in Chrome DevTools and Safari Inspector; Firefox dev tools reportedly less so.

@spiralx
spiralx / object-observe-examples.md
Last active December 14, 2016 15:47 — forked from addyosmani/examples.md
Object.observe() examples from my talk

What are we trying to observe? Raw object data.

// Objects
var obj = { id: 2 };
obj.id = 3; // obj == { id: 3 }
 
// Arrays
var arr = ['foo', 'bar'];
arr.splice(1, 1, 'baz'); // arr == ['foo', 'baz'];
@spiralx
spiralx / bling.js
Last active November 15, 2016 15:39 — forked from paulirish/bling.js
bling.js fork with multiple event binding
/*jshint asi:true, proto:true */
/* bling.js */
window.$ = document.querySelectorAll.bind(document)
Node.prototype.on = window.on = function(names, fn) {
var self = this
names.split(' ').forEach(function(name) {