Skip to content

Instantly share code, notes, and snippets.

View tbassetto's full-sized avatar

Thomas Bassetto tbassetto

View GitHub Profile
// Minimalist class (className) manipulation library
var klass = {
has: function(elem, name) {
return (' '+elem.className+' ').indexOf(' '+name+' ') != -1;
},
add: function(elem, name) {
if(!klass.has(elem, name)) {
elem.className += ' '+name;
}
},
#context-sendpage, #context-sendlink, #context-sendimage, #context-setDesktopBackground,
#context-bookmarklink, #context-savelink, #context-searchselect,
#context-bookmarkpage, #context-savepage, #context-sep-open, #context-sep-viewbgimage,
#urlbar .urlbar-history-dropmarker, #star-button
{
display: none !important;
}
#urlbar-icons {
margin-right: 2px;
@mauricesvay
mauricesvay / gist:736880
Created December 10, 2010 21:53
Abusing localStorage to build an aggressive cache
var assets = [
'http://localhost/offline-assets/fancybox/jquery.fancybox-1.3.4.js',
'http://localhost/offline-assets/fancybox/jquery.fancybox-1.3.4.css'
];
for (var i=0,l=assets.length; i<l; i++) {
loadAsset(assets[i]);
}
function loadAsset(url){
@creationix
creationix / find.js
Created December 24, 2010 23:49
Find all references to an object.
function find(root, obj) {
var seen = [];
function search(root, name, depth) {
if (root === obj) {
console.log(name);
return;
}
if (!depth) { return; }
if (seen.indexOf(root) >= 0) { return; }
if (typeof root !== "object") { return; }
@rwaldron
rwaldron / h264.html
Created February 3, 2011 00:06
H264 Support Revision
<!DOCTYPE html>
<html>
<head>
<title>H264</title>
<script src="h264.js"></script>
</head>
<body>
@mklabs
mklabs / simple-cache-system.js
Created February 12, 2011 14:23
A module that acts as a service to request localy stored markdown file, this version includes a simple cache wrapper
var markdownService =(function(){
var cache = function(fn){
var c = {};
return function(file, cb) {
var item = c[file],
_cb = cb,
cb = function(r) {
var cFile = c[file];
@lsmith
lsmith / iOS_details_arrow.css
Created March 6, 2011 07:56
The CSS to create an iOS details call-to-action arrow
/* assumes .details is position: relative */
.details::after {
content: '';
position: absolute;
border-top: 3px solid #7f7f7f;
border-right: 3px solid #7f7f7f;
height: 6px;
width: 6px;
top: 50%;
right: 12px;
@creationix
creationix / coorspin.html
Created March 6, 2011 22:54
A re-implementation of ColorSpin from iOS to webOS.
<!doctype html>
<html>
<head>
<title>ColorSpin</title>
<meta name="viewport" content="width=device-width,height=device-height,initial-scale=1.0,user-scalable=no"/>
<style>
html { height: 100%; }
body {
height: 100%;
margin: 0;
// A simple module to replace `Backbone.sync` with *localStorage*-based
// persistence. Models are given GUIDS, and saved into a JSON object. Simple
// as that.
// Generate four random hex digits.
function S4() {
return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
};
// Generate a pseudo-GUID by concatenating random hexadecimal.
@angus-c
angus-c / I_can_haz_10.lol
Created April 28, 2011 18:32
I can haz 10?
HAI
CAN HAS STDIO?
I HAS A VAR
IM IN YR LOOP
UP VAR!!1
VISIBLE VAR
IZ VAR BIGGER THAN 10? KTHXBYE
IM OUTTA YR LOOP
KTHXBYE