Skip to content

Instantly share code, notes, and snippets.

View wmbenedetto's full-sized avatar

Warren Benedetto wmbenedetto

  • Foothill Ranch, CA
View GitHub Profile
@wmbenedetto
wmbenedetto / css3BackgroundAnimation.html
Last active April 12, 2016 12:58
Animating a background gradient with CSS3 to mimic the iPhone's slide-to-unlock screen
<html>
<head>
<title>CSS3 Slide to unlock</title>
<style type="text/css">
body {
background:#333;
}
.slider-text {
@wmbenedetto
wmbenedetto / deflate.js
Last active December 14, 2015 11:38
Converts a multi-dimensional object to single-dimensional object in JavaScript. Dot-notated paths are used as object keys to represent nesting depth and to facilitate re-inflation.
/* Adding deflate() to the Object prototype */
Object.prototype.deflate = function(pathArray,result){
pathArray = (typeof pathArray === 'undefined') ? [] : pathArray;
result = (typeof result === 'undefined') ? {} : result;
var key, value, newKey;
for (var i in this){
@wmbenedetto
wmbenedetto / lookup.js
Last active December 14, 2015 11:28
The examples in this gist will let you look up a property in a nested JavaScript object using a dot-delimited object path. A string like `foo.bar.baz` can be used to look up the value of `baz` in an object where baz is nested inside of bar which is nested inside of foo.
var lookup = function(dotPath,sourceObj){
var parts = dotPath.split('.');
var lastPart = parts.pop();
var len = parts.length;
var counter = 1;
var current = parts[0];
while ((sourceObj = sourceObj[current]) && counter < len){
current = parts[counter];