Skip to content

Instantly share code, notes, and snippets.

View simonklee's full-sized avatar

Simon Klee simonklee

View GitHub Profile

Search Tips

Hierarchical search helps you find information related to specific modules, classes, or categories:

  • Enter the higher-level term first, followed by the specific term
  • Example: "fs windows" to find declarations in fs containing windows

Order of search terms can affect the prioritization of the results:

  • Changing order affects prioritization of results
#!/bin/bash
if [ -z "$1" ]; then
MB=1024
else
MB="$1"
fi
if [ -z "$2" ]; then
browser="google-chrome-beta"
@simonklee
simonklee / index.html
Created May 26, 2015 10:24
event listener and event bubbling.
<html>
<head>
<style>
body, html, canvas {
margin: 10px;
padding: 0;
}
#text-input {
@simonklee
simonklee / bench.rs
Last active August 29, 2015 14:21
bench loops
#![feature(test)]
extern crate test;
use test::Bencher;
#[bench]
fn for_range_100(b: &mut Bencher) { b.iter(|| { test::black_box(for _ in 0..100 {}); }); }
#[bench]
@simonklee
simonklee / index.html
Last active August 29, 2015 14:15
sort
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>sort</title>
<script>
function isNumeric(input) {
return (input - 0) == input && (''+input).trim().length > 0;
}
#!/bin/bash
# takes a backup of node
workdir=null
datavol=""
pidfile="/tmp/backup-node.pid"
declare -A backup_nodes=()
# timings
@simonklee
simonklee / intersect-redis.py
Created March 18, 2014 22:14
measure inter
#!/usr/bin/env python
import time
import redis
import random
c = redis.StrictRedis()
for online in ("online-10000", "online-50000", "online-100000"):
c.delete(online)
@simonklee
simonklee / banner-landing.html
Created February 24, 2014 08:34
spil ads like googletags
<div id='kogama_970x90'>
<script type='text/javascript'>
spilAdsManager.cmd.push(function() {
spilAdsManager.display('kogama_970x90');
});
</script>
</div>
@simonklee
simonklee / gist:8842786
Last active August 29, 2015 13:56
Domain whitelist
import re
class DomainWhitelist(object):
url_re = re.compile(
r'([a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,6})',
re.IGNORECASE)
kogama_re = re.compile(
r'^(http[s]?://)?([a-z0-9-.]{2,8})?kogama.com(.br)?',
re.IGNORECASE)
@simonklee
simonklee / sql-norace.go
Created November 10, 2013 11:58
go build -race
package main
import (
"os"
"database/sql"
"fmt"
"sync"
_ "github.com/go-sql-driver/mysql"
)