Instantly share code, notes, and snippets.

View Scene.js
/*
#scenes .scene.animate{transition: left 0.7s;}
#scenes .scene.in{left:0;}
#scenes .scene.left{left:-100%;}
#scenes .scene.right{left:100%;}
*/
var Scene = (function () {
var scenes = [];
var sceneSequence = '0';
View base.css
/* reset */
html {
-webkit-text-size-adjust: 100%;
}
button {
-webkit-tap-highlight-color: rgba(255,255,255,0);
-webkit-tap-highlight-color: transparent;
outline: 0 none;
}
button::-moz-focus-inner {
View today.js
const now = new Date();
const YMD = `${now.getFullYear()}-${`0${now.getMonth() + 1}`.slice(-2)}-${`0${now.getDate()}`.slice(-2)}`;
const His = `${now.getHours()}:${now.getMinutes()}:${now.getSeconds()}`
View console.log.to.div.html
<div id="trace" style="position: absolute; z-index: 99999; top: 0; right: 0; border: 2px solid #0c0; background: #fff; color: #0c0; font: 11px monospace;"></div>
<script>
var console = {
log: function trace() {
var msg = Array.prototype.slice.call(arguments).join(' ');
document.getElementById('trace').innerHTML += msg.toString() + '<br>';
}
}
console.log(navigator.userAgent);
</script>
View setPhotoSize.js
_setPhotoSize: function($image) {
var cropPortion = 1.2,
imageWidth = $image.width(),
imageHeight = $image.height(),
imageRatio = imageWidth / imageHeight,
windowWidth = LayoutManager().getScreenWidth(),
windowHeight = LayoutManager().getScreenHeight(),
windowRatio = windowWidth / windowHeight,
width, height, top = 0, left = 0;
View layerOpen.js
// TODO: Add complete HTML document.
$layer: $('.layer'),
$button: $('.button'),
_initialize: function() {
$(document).on('click', this._onClick.bind(this));
},
_onClick: function(event) {
View ajax.js
// Minimal Ajax function https://gist.github.com/hyeonseok/604812e389aa9e74d346
function ajax(u,c,d){var x=new(this.XMLHttpRequest||ActiveXObject)("Microsoft.XMLHTTP");x.onreadystatechange=function(){this.readyState^4||c(this)};if(d){x.open('POST',u);x.setRequestHeader('Content-type','application/x-www-form-urlencoded')}else{x.open('GET',u)}x.send(d)}
/*
GET request
ajax('whatever.php?foo=bar', function (xhr) {
console.log(xhr.responseText);
});
POST request
ajax('whatever.php', function (xhr) {
View SwapScroll.js
// Needs to be clean up.
var mainContent = document.getElementById('main');
var open = function (target) {
var closeButton = target.querySelector('p.button button');
mainContent.style.top = -1 * document.body.scrollTop + 'px';
mainContent.style.position = 'fixed';
target.setAttribute('aria-hidden', 'false');
document.body.scrollTop = 0;
closeButton.addEventListener('click', close);
View transparent-data-uri.gif.txt
# blank
data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
# 10% black
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAADUExURQkJCQC1BbgAAAABdFJOUxq9hCEcAAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg==
# 20% black
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAADUExURQoKBSBopAkAAAABdFJOUzP/NrlwAAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg==
# 30% black
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAADUExURQ0JBpcDsPUAAAABdFJOU01Ii+VLAAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg==
# 40% black