Skip to content

Instantly share code, notes, and snippets.

@uniqname
uniqname / exposure.js
Created November 29, 2012 14:16
js function for exposure django app
exposure = function () {
/*
RETURNS: An exposure URL which returns the specified image resized to specified height and width
ARGUMENTS: object || url:string [, height:string||int] [, width:string||int]
The exposure method takes either an object or one or more strings as arguments.
A value of "0" for "width" or "height" indicates that exposure should use a value
that maintains the image's native aspect ratio.
@uniqname
uniqname / gist:4683217
Created January 31, 2013 14:30
Extension of location object to get the site name (of SLD, second level domain) of either the document's URL or from a given URL.
/*************
* Custom siteName functionality
* window.location.siteName reduces a either the documents url or a
* given url to the top most site name.
* i.e. photography.nataionalgeographic.com would return nationalgeographic.com,
* mysubdomain.mywebsite.co.uk would return mywebsite.co.uk.
***********/
if (typeof window.location.siteName === 'undefined') {
window.location.siteName = function (url) {
var hostName = url || window.location.hostname,
@uniqname
uniqname / infiniteStash.js
Last active December 18, 2015 04:19
Stash and unstash nodes in potentially very long list of childNodes.
;(function (window, document, $, undefined) {
var module, moduleName, stash, unstash, noconflict, oldGlobal;
moduleName = 'infiniteStash';
stash = function (containerNode, numNodesToStash, after) {
var side = (after === true || after === 'after') ? 'after' : 'before',
// set is uesd to stash all node up to the next element.
// This preserves text nodes (white space) and comment nodes
@uniqname
uniqname / DOMTreePath
Created December 5, 2013 15:37
Find a path from one node to another
var getPath = function (start, end) {
var getParents = function (el) {
var parents = [el];
el = el.parentElement;
while (el.parentElement) {
parents.push(el = el.parentElement);
}
@uniqname
uniqname / legalIpsum.js
Created March 4, 2014 21:28
Legal Ipsum
(function() {
var words = [" a fortiori", "a mensa et thoro", "a posteriori", "a priori", "a quo", "ab extra", "ab initio", "absque hoc", "Actori incumbit probatio", "actus reus", "ad coelum", "ad colligenda bona", "ad hoc", "ad hominem", "ad idem", "ad infinitum", "ad litem", "ad quod damnum", "ad valorem", "adjournment sine die", "affidavit", "alter ego", "amicus curiae", "animus nocendi", "animus possidendi", "animus revertendi", "ante", "arguendo", "Audi alteram partem", " bona fide", "bona vacantia", " Cadit quaestio", "Casus belli", "casus fortuitus", "Caveat", "Caveat emptor", "Certiorari", "Ceteris paribus", "cogitationis poenam nemo patitur", "compensatio morae", "compos mentis", "Condicio sine qua non", "consensus ad idem", "consensus facit legem", "consuetudo pro lege servatur", "contra", "contra bonos mores", "contra legem", "Contradictio in adjecto", "contra proferentem", "coram non judice", "corpus delicti", "corpus juris", "corpus juris civilis", "corpus juris gentium", "corpus juris secund
@uniqname
uniqname / polyPict.js
Created April 9, 2014 20:47
polyPict - <picture> polyfill
(function() {
window.addEventListener("DOMContentLoaded", function() {
//Use live-node-lists here so we don't have to query the DOM everytime polyPict runs.
var picturesLNL = document.getElementsByTagName("picture"),
imgLNL = document.getElementsByTagName("img"),
size2Px = (function() {
var testEl = document.createElement("div");
testEl.style.position = "absolute";
testEl.style.zIndex = -1000;
@uniqname
uniqname / SassMeister-input.scss
Created October 8, 2014 14:48
Generated by SassMeister.com.
// ----
// Sass (v3.4.4)
// Compass (v1.0.1)
// ----
$positions: (top, right, bottom, left);
.stretch {
position: absolute;
@each $pos in $positions {
@uniqname
uniqname / SassMeister-input.scss
Created November 26, 2014 22:38
Generated by SassMeister.com.
// ----
// Sass (v3.3.14)
// Compass (v1.0.1)
// ----
//Media Queries
$mq-size--small: 42em;
$mq-size--med: 47.5em;
$mq-size--large: 56.25em;
@uniqname
uniqname / SassMeister-input.scss
Created December 1, 2014 20:38
Generated by SassMeister.com.
// ----
// Sass (v3.3.14)
// Compass (v1.0.1)
// ----
.full {
@each $pos in ("top", 'left', bottom, right) {
#{$pos}: 0;
}
}

JS REPL

There's not a good, simple embeddable REPL for JS out there that I could find. I wanted one for presentations on JavaScript concepts. The developer tools' console would be ideal, but bailing out of my presentation and opening a console brakes the flow. Tools like codepen.io et al. are great, but more overhead and set up than I need. I just want to type JS and show the result. This is a decent first step for my needs.

A Pen by Cory on CodePen.

License.