Skip to content

Instantly share code, notes, and snippets.

View markus1189's full-sized avatar

Markus Hauck markus1189

  • Frankfurt am Main, Germany
View GitHub Profile
@lucashungaro
lucashungaro / links.textile
Created August 14, 2010 16:36
Links de referência utilizados em minha palestra
@jamis
jamis / ellers.rb
Created December 24, 2010 03:17
An implementation of Eller's algorithm for generating mazes
# --------------------------------------------------------------------
# Eller's algorithm for maze generation. Novel in that it only
# requires memory proportional to the size of a single row; this means
# you can generate "bottomless" mazes with it, that just keep going
# and going and going, using not only constant memory, but little
# memory in general.
# --------------------------------------------------------------------
# --------------------------------------------------------------------
# 1. Allow the maze to be customized via command-line parameters
@rampion
rampion / RedBlackTree.hs
Created May 11, 2012 13:55
red-black trees in haskell, using GADTs and Zippers
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE StandaloneDeriving #-}
module RedBlackTree where
data Zero
data Succ n
type One = Succ Zero
data Black
@ivanacostarubio
ivanacostarubio / software_abstractions.txt
Created May 22, 2012 23:23
Build the right software abstractions.
"Pick the right ones, and programming will flow naturally from design;
modules will have small and simple interfaces; and new functionality will
more likely fit in without extensive reorganization.
Pick the wrong ones, and programming will be a series of nasty surprises:
interfaces will become baroque and clumsy as they are forced to accommodate
unanticipated interactions, and even the simplest of changes will be hard to make."
MIT Professor Daniel Jackson
@jboner
jboner / latency.txt
Last active June 19, 2024 05:25
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
@garybernhardt
garybernhardt / selectable_queue.rb
Last active November 23, 2022 12:42
A queue that you can pass to IO.select.
# A queue that you can pass to IO.select.
#
# NOT THREAD SAFE: Only one thread should write; only one thread should read.
#
# Purpose:
# Allow easy integration of data-producing threads into event loops. The
# queue will be readable from select's perspective as long as there are
# objects in the queue.
#
# Implementation:
@X4
X4 / krawall.sh
Last active January 7, 2018 09:55
Krawall is a "Wallpaper Changer" for all common desktop environments (xfce4, i3/xmonad, enlightenment (e17), gnome2, gnome3, kde3 and kde4)
#!/bin/bash
# -------------------------------------------------------
# @author X4
# @version 1.0
#
# HowTo:
# You can add a new GlobalHotkey to the media forward an back buttons for example.
# There are other ways to run this script: Button or Keypresses, Plasmoids, Events..
#
# Use these parameters when on XFCE for example:
@gbl08ma
gbl08ma / tny
Created July 30, 2013 17:40
Unix shell script to shorten URLs with tny.im URL shortener. wget must be installed for this to work.
#!/bin/sh
if [ -t 0 ]; then
if [ -z "$1" ]; then
echo "usage: tny long_url [custom_keyword]"
echo ""
echo "Shorten URLs with tny.im URL shortener"
echo "This script expects a long URL to shorten either as an argument or passed through STDIN."
echo "When using arguments, an optional second argument can be provided to customize the later part of the short URL (keyword)."
exit 1
fi
@merijn
merijn / gist:6130082
Last active January 2, 2019 10:07
Type family that disallows certain types for type variables.
{-# LANGUAGE ConstraintKinds, DataKinds, PolyKinds, TypeFamilies, TypeOperators #-}
import GHC.Exts (Constraint)
type family Restrict (a :: k) (as :: [k]) :: Constraint where
Restrict a (a ': as) = ("Error!" ~ "Tried to apply a restricted type!")
Restrict x (a ': as) = Restrict x as
Restrict x '[] = ()
foo :: Restrict a [(), Int] => a -> a