Skip to content

Instantly share code, notes, and snippets.


Justin Perry ourmaninamsterdam

View GitHub Profile
ourmaninamsterdam / gist:4555503
Last active Dec 11, 2015
Finds and removes item from array
View gist:4555503
* remove_from_array()
* Based on str param supplied, finds and removes matching item from array
* @param {Array} array Array to query
* @param {String} str String to look for
* @return {Bool} returns true after item is found and remove from array
function remove_from_array(array, str) {
var i;
for(i = 0; i < array.length; i++){
ourmaninamsterdam / gist:4555610
Created Jan 17, 2013
Returns an array of values from a JSON array
View gist:4555610
* get_keys()
* @param {Array} data JSON array
* @param {String} label Value to return
* @return {Array} array of matched property
function get_keys(data, label) {
var key, values = [];
for(key in data){
ourmaninamsterdam / jquery.microcarousel.js
Last active Feb 23, 2019
Super compact jQuery vertical text carousel plugin, with variable content-based slide latency. < 0.5k minified.
View jquery.microcarousel.js
;(function($) {
$.fn.microcarousel = function(options) {
var settings = $.extend({
timer_latency : 40
}, options);
return this.each(function() {
var timer, $wrapper = $(this);
ourmaninamsterdam / index.html
Last active Dec 11, 2015
**BETA**. jQuery plugin to independently animate elements using their data attributes used for animation properties.
View index.html
<!DOCTYPE html>
<html lang="en-gb">
<meta charset="utf-8" />
background: #ccc;
box-sizing: border-box;
height: 100px;
ourmaninamsterdam / simple-pagination.html
Created Jan 24, 2013
Simple JS pagination script that can be easily modified to accept a JSON array. Known bug where pages 11-20 are skipped when paging through.
View simple-pagination.html
<!DOCTYPE html>
<html lang="en-GB">
<title>Simple JavaScript pagination</title>
<meta charset="UTF-8">
position: relative;
ourmaninamsterdam / gist:5232000
Created Mar 24, 2013
Get computed style of elements and pseudo elements
View gist:5232000
function getComputedStyle(elem, property, pseudoelem){
return window.getComputedStyle(elem, (pseudoelem || null)).getPropertyValue(property);
getComputedStyle(myElem, "height").width;
getComputedStyle(myElem, "height", ":after").width;
ourmaninamsterdam / gist:5319295
Created Apr 5, 2013
Dustin Diaz object string supplanter
View gist:5319295
function substitute(s, o){
return s.replace( /{([^{}]*)}/g ,
function (a, b) {
var r = o[b];
return typeof r === 'string' || typeof r === 'number' ? r : a;
substitute("My name is {name} and I work at {workplace}",{
name: "Justin Perry",
ourmaninamsterdam / accordion.css
Last active Dec 16, 2015
Pure CSS3 Accordion with Deep link and inter-slide navigation. Haven't tested but should work IE8, just without animations. No fallbacks for IE7 at this time. Trying to figure out how to close an open slide when clicking the open link again.
View accordion.css
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
margin: 0;
padding: 0;
html {
ourmaninamsterdam / gist:5370657
Last active Dec 16, 2015
Debug list. Accepts primitive values and arrays.
View gist:5370657
function log(){
var debug = document.getElementById('debug'),
reverse = true,
log = arguments, 0 ).join('{join}').replace(/{join}/g, '<br>');
debug.innerHTML = (reverse)? log + '<br>' + debug.innerHTML : debug.innerHTML + '<br>' + log;
log(, myObject.thing, 'With a label: ' + myObject.label);
ourmaninamsterdam / gist:5370671
Last active Dec 16, 2015
Filters an array based on filter. Accepts regex or simple string. Returns a filtered array.
View gist:5370671
var filter = '.png';
var list = ['userimage105325.png','userimage669.jpg','userimage6929.png','userimage85818.gif'];
function filterArray(array, filter){
var i, filteredArray = [];
filter = new RegExp(filter, 'g');
for( i = 0, len = array.length; i < len; i++ ){
if( array[i].toString().match(filter) ){
filteredArray.push( array[i] );