Skip to content

Instantly share code, notes, and snippets.

@to
to / gist:2440268
Created April 21, 2012 23:35
border-radius clipping
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">
.frame {
width: 100px;
height: 100px;
border: 5px solid black;
@to
to / gist:2467294
Created April 22, 2012 22:22
Array.prototype.stack
Array.prototype.stack = function(array){
this.push.apply(this, array);
}
@to
to / gist:2763390
Created May 21, 2012 17:22
String, ==, ===
var arr1 = [];
var arr2 = [];
for(var i=0 ; i<1000000 ; i++){
arr1.push(i);
arr2.push(i);
}
var str1 = arr1.join(',');
var str2 = arr2.join(',');
bench('==', function(){return str1 == str2});
@to
to / gist:2815905
Created May 27, 2012 21:07
Chrome, Object, keys, order
function is(got, expected){
got != expected && alert(['FAIL', got, expected].join(', '));
}
function keys(o){
var r = [];
for(var p in o)
r.push(p);
return r;
}
@to
to / gist:2886473
Created June 7, 2012 03:56
Fake Pageshow Event for iOS Home App
var time = Date.now();
setInterval(function(){
var now = Date.now();
if(now - time > 5000)
alert('pageshow(fake)');
time = now;
}, 1000);
@to
to / gist:2913882
Created June 12, 2012 01:40
Window Size, Media Query
<!doctype html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0">
</head>
<body>
<pre id="out"></pre>
</body>
<script>
function checkSizes(){
@to
to / gist:2916336
Created June 12, 2012 09:03
Bench, Method vs Grobal Function
var text = new Array(500).join('-');
String.prototype.getLength = function(){
return this.length;
}
function getLength(str){
return str.length;
}
@to
to / cache.manifest
Created June 28, 2012 14:24
Offline Application Cache on iOS 5
CACHE MANIFEST
NETWORK:
*
// ==UserScript==
// @id www.rbmaradio.com-9a6f2253-11bd-4aa4-9f5c-cadfa1899da0@scriptish
// @name RBMA Radio - Add Download Link
// @include http://www.rbmaradio.com/shows/*
// @run-at window-load
// ==/UserScript==
var url = unsafeWindow.gon.show.akamai_url;
var ul = document.querySelector('.l-more ul');
// ==UserScript==
// @id vapor.strobes-34539d25-662b-4891-877a-706e35258457@scriptish
// @name Vapor Strobes
// @version 1.0
// @namespace to.tumblr.com
// @author to
// @include *
// @run-at document-end
// ==/UserScript==