Skip to content

Instantly share code, notes, and snippets.

View branneman's full-sized avatar

Bran van der Meer branneman

View GitHub Profile
@remy
remy / gist:350433
Created March 31, 2010 14:58
Storage polyfill
if (typeof window.localStorage == 'undefined' || typeof window.sessionStorage == 'undefined') (function () {
var Storage = function (type) {
function createCookie(name, value, days) {
var date, expires;
if (days) {
date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
expires = "; expires="+date.toGMTString();
.whatever {
-webkit-box-shadow: 0 2px 2px rgba(0,0,0,0.5) inset;
-moz-box-shadow: 0 2px 2px rgba(0,0,0,0.5) inset;
-o-box-shadow: 0 2px 2px rgba(0,0,0,0.5) inset;
box-shadow: 0 2px 2px rgba(0,0,0,0.5) inset;
}
@krijnhoetmer
krijnhoetmer / gist:1109243
Created July 27, 2011 12:21
CSS 'build' thingy
<?php
$src = 'foo { border-radius: 4px; }
bar { box-shadow: 5px 0 0 rgba(0, 0, 0, .5);
baz { background-image: url(img/baz.png); }
quux { background-image: url(img/quuz.png#!); }';
preg_match_all('/url\((.*\.png)\)/U', $src, $matches);
foreach ($matches[1] as $match) {
$src = str_replace($match, 'data:image/png;base64,' . base64_encode(file_get_contents($match)), $src);
@vasilisvg
vasilisvg / responsive-context-images.html
Created September 7, 2011 10:50
Responsive context aware images without cookies or server logic
<!doctype html>
<!--
WARNING!
You probably shouldn't use this technique since images never show up
if the script isn't loaded for one reason or another. Some reasons:
- The content is viewed using a RSS reader
- The content is viewed with a read-it-later service
- The user has a flaky connection (hotel wifi, Dutch train, etc)
-->
@pixelpogo
pixelpogo / gist:1222411
Created September 16, 2011 15:50
How to simulate low bandwidth on mac os x
# try
# 48kbit/s for Dialup
# 64kbit/s for Edge
# 384kbit/s for 3G
# 768kbit/s for DSL
# 1572kbit/s for T1
#
# to simulate low bandwidths.
#
# And: You can play with the delay option.
@guileen
guileen / async.js
Created March 11, 2012 15:59
parallel javascript
// This is an lite version of `async`, see https://github.com/caolan/async
//
// es5shim.js is required for old version browsers
//
// Author: Gui Lin
// Email: guileen@gmail.com
var async = {};
@haschek
haschek / .jshintrc
Created May 4, 2012 16:08
JSHint Configuration, Strict Edition
{
// --------------------------------------------------------------------
// JSHint Configuration, Strict Edition
// --------------------------------------------------------------------
//
// This is a options template for [JSHint][1], using [JSHint example][2]
// and [Ory Band's example][3] as basis and setting config values to
// be most strict:
//
// * set all enforcing options to true
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@naholyr
naholyr / _service.md
Created December 13, 2012 09:39
Sample /etc/init.d script

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
@boschni
boschni / commit-msg
Last active January 11, 2017 10:29
Git commit hook to automatically add branch name to every commit message. Put in ".git/hooks/commit-msg" and give the file execute rights.
#!/bin/sh
#
# Automatically adds branch name to every commit message.
#
NAME=$(git branch | grep '*' | sed 's/* //')
if [ -n "$NAME" ]
then
if [ "$NAME" = "master" ]
then
echo $(cat "$1") > "$1"