Skip to content

Instantly share code, notes, and snippets.

View sk1p's full-sized avatar

Alexander Clausen sk1p

  • Jülich, Germany
View GitHub Profile
@anandbaburajan
anandbaburajan / rec.py
Last active July 12, 2021 16:43
K2 simulator
import click
import struct
import socket
BLOCK_SIZE = 0x5758
GROUP = "225.1.1.1"
@click.command()
@click.option("--port", type=int)
@Komzpa
Komzpa / upgrade-postgres-9.4-to-9.5-to-9.6-to-10.md
Last active May 13, 2025 22:06 — forked from dideler/upgrade-postgres-9.3-to-9.4.md
Upgrading PostgreSQL from 9.4 to 9.5 to 9.6 to 10 when upgrading Ubuntu 14.10 to 16.04

TL;DR

9.4 -> 9.5:

sudo pg_dropcluster 9.5 main --stop
sudo service postgresql stop
sudo pg_upgradecluster -m upgrade -k 9.4 main
sudo su postgres -c "/usr/lib/postgresql/9.5/bin/vacuumdb --all --analyze-in-stages"
sudo pg_dropcluster 9.4 main
# Get a list of all the bugs you fixed:
hg log -u your@email.com --template '{date|isodate}: {desc}\n'
# it doesn't filter out the merges, backouts, etc.
# Add this to your hgrc:
[alias]
mybugs = log -u your@email.com --template '{date|isodate}: {desc}\n'
hg mybugs
@jboner
jboner / latency.txt
Last active November 1, 2025 21:13
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
Basey = OpenLayers.Class(OpenLayers.Control, {
layerStates: null,
layersDiv: null,
ascending: true,
initialize: function(options) {
OpenLayers.Control.prototype.initialize.apply(this, arguments);
this.layerStates = [];
},
@scottjehl
scottjehl / getViewportSize.js
Created March 16, 2012 19:25
Reliably get viewport dimensions in JS
/*!
An experiment in getting accurate visible viewport dimensions across devices
(c) 2012 Scott Jehl.
MIT/GPLv2 Licence
*/
function viewportSize(){
var test = document.createElement( "div" );
test.style.cssText = "position: fixed;top: 0;left: 0;bottom: 0;right: 0;";
@standardpixel
standardpixel / Three step map zoom example
Created February 6, 2012 08:02
This is a simple library agnostic example of Flickr's three step map zoom.
/*
* This is a simple library agnostic example of Flickr's three step map zoom.
* In this example we are using the open mapquest static map api. Preloading
* of second and third map images can be done before mouseover to make their
* first display smoother.
*/
<style>
#map_container {
width:300px;
@justquick
justquick / GFKManager.py
Created September 12, 2011 05:12 — forked from dexterbt1/GFKManager.py
django generic foreignkey manager
from django.db.models.query import QuerySet
from django.db.models import Manager
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes.generic import GenericForeignKey
class GFKManager(Manager):
"""
A manager that returns a GFKQuerySet instead of a regular QuerySet.
"""
@jezdez
jezdez / gloss.py
Created August 24, 2011 10:10
A dictionary like object that supports attribute access, too.
import copy
class gloss(dict):
"""
A dictionary like object that supports attribute access, too.
>>> import pickle
>>> s = gloss(a=123)
>>> c = s.copy()