Skip to content

Instantly share code, notes, and snippets.

@jlbruno
jlbruno / isItScrollableWithoutVisibleScrollbars.js
Created July 22, 2011 18:54
a function to check if a certain element is scrollable, but is NOT showing scrollbars. Useful to use as a test for when you might want to implement another scrolling solution, such as iScroll for iPad.
var isItScrollableWithoutVisibleScrollbars = function(el) {
if (el === null) {
return false;
}
var isScrollable = false;
var hasScrollbars = false;
// first, lets find out if it has scrollable content
isScrollable = el.scrollHeight > el.offsetHeight ? true : false;
// if it's scrollable, let's see if it likely has scrollbars
if (isScrollable) {
@kylelemons
kylelemons / enum.go
Created September 8, 2011 18:49
Enum types (bitshifted too)
package main
import (
"fmt"
"strings"
)
type foo int
const (
One foo = iota
@kylelemons
kylelemons / enum.go
Created October 23, 2011 17:26
Enumerations in Go with string names
package main
import "fmt"
type day int
const (
Sunday day = iota
Monday
Tuesday
Wednesday
@mathiasverraes
mathiasverraes / .bashrc
Created November 3, 2011 18:46 — forked from thomasvm/.bashrc
Git shortcuts
#! /bin/sh
alias gs="git status"
alias gc="git commit"
alias gr="git checkout"
alias ga="git add"
alias gl="git lola"
@jboner
jboner / latency.txt
Last active May 28, 2024 18:39
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@mbostock
mbostock / .block
Last active March 6, 2019 05:06 — forked from mbostock/.block
Contour Plot
license: gpl-3.0
height: 673
border: no
redirect: https://observablehq.com/@d3/volcano-contours
@gythialy
gythialy / gson.java
Last active July 11, 2021 07:30
Gson support Guava MutiMap and Table
package com.wescon.cv.utilities;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.nutz.castor.Castors;
@trusktr
trusktr / DefaultKeyBinding.dict
Last active May 21, 2024 19:41
My DefaultKeyBinding.dict for Mac OS X
/* ~/Library/KeyBindings/DefaultKeyBinding.Dict
This file remaps the key bindings of a single user on Mac OS X 10.5 to more
closely match default behavior on Windows systems. This makes the Command key
behave like Windows Control key. To use Control instead of Command, either swap
Control and Command in Apple->System Preferences->Keyboard->Modifier Keys...
or replace @ with ^ in this file.
Here is a rough cheatsheet for syntax.
Key Modifiers
@zchee
zchee / actionlist.vim
Last active May 27, 2024 19:41
IdeaVim actionlist
--- Actions ---
$Copy <M-C>
$Cut <M-X> <S-Del>
$Delete <Del> <BS> <M-BS>
$LRU
$Paste <M-V>
$Redo <M-S-Z> <A-S-BS>
$SearchWeb <A-S-G>
$SelectAll <M-A>
$Undo <M-Z>
@neilvallon
neilvallon / rdp.go
Last active August 27, 2020 15:15
In-place Ramer–Douglas–Peucker for Go & TypeScript
package rdp
import "math"
type point [2]float64 // [x, y]
// RDPSimplify is an in-place implementation of Ramer–Douglas–Peucker.
func RDPSimplify(points []point, epsilon float64) []point {
return points[:rdpCompress(points, epsilon)]
}