This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta content="text/html; charset=utf-8" http-equiv="Content-type" /> | |
<title>Animated Bars</title> | |
<meta content="width=device-width, initial-scale=1" name="viewport" /> | |
<style type="text/css"> | |
body{ | |
margin:0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function makeJSONDownload(evt) { | |
window.URL = window.URL || window.webkitURL; | |
var content = JSON.stringify(p); | |
var blob = new Blob([content], {type: 'application/json'}); | |
var link = document.createElement('a'); | |
link.href = window.URL.createObjectURL(blob); | |
link.textContent = 'download here'; | |
link.download = 'test.json'; | |
document.getElementById('div').appendChild(link); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta content="text/html; charset=utf-8" http-equiv="Content-type" /> | |
<title>Playground</title> | |
<meta content="width=device-width, initial-scale=1" name="viewport" /> | |
<style type="text/css"> | |
body{ | |
margin:0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (window.File && window.FileReader && window.FileList && window.Blob) { | |
// Great success! | |
function handleJSONDrop(evt) { | |
evt.stopPropagation(); | |
evt.preventDefault(); | |
var files = evt.dataTransfer.files; | |
// Loop through the FileList and read | |
for (var i = 0, f; f = files[i]; i++) { | |
// Only process json files. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (window.File && window.FileReader && window.FileList && window.Blob) { | |
// Great success! | |
function handleFileSelect(evt) { | |
var files = evt.target.files; | |
// files is a FileList (object) of File objects. List some properties. | |
var output = []; | |
for (var i = 0, f; f = files[i]; i++) { | |
output.push('<li><strong>', escape(f.name), '</strong> (', f.type || 'n/a', ') - ', | |
f.size, ' bytes, last modified: ', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$im = file_get_contents('<image url here>'); | |
$imdata = base64_encode($im); | |
?> | |
<img src="data:image/png;base64,<?php echo $imdata; ?>" /> | |
or | |
<img src="data:image/jpg;base64,<?php echo $imdata; ?>" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function add (verb, a, b) { | |
return "The " + verb + " of " + a + ' and ' + b + ' is ' + (a + b) | |
} | |
add('sum', 5, '6') | |
//=> 'The sum of 5 and 6 is 11' | |
// Here is the curried version: | |
function addCurried (verb) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function escapeHtml(str) { | |
var div = document.createElement('div'); | |
div.appendChild(document.createTextNode(str)); | |
return div.innerHTML; | |
}; | |
function unescapeHtml(escapedStr) { | |
var div = document.createElement('div'); | |
div.innerHTML = escapedStr; | |
var child = div.childNodes[0]; | |
return child ? child.nodeValue : ''; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.judo = { | |
scrollTo: function(element, to, duration) { | |
var start = element.scrollTop, | |
change = to - start, | |
currentTime = 0, | |
increment = 20, | |
easeInOutQuad = function (t, b, c, d) { | |
t /= d/2; | |
if (t < 1) return c/2*t*t + b; | |
t--; |