Skip to content

Instantly share code, notes, and snippets.

View iomonad's full-sized avatar
🍋
λ

iomonad iomonad

🍋
λ
  • Lutetia Parisiorum
View GitHub Profile
@snb
snb / virtualbox_ports.png
Created January 24, 2010 01:46
virtualbox serial console
virtualbox_ports.png
@chrisjacob
chrisjacob / README.md
Created February 14, 2011 14:31
Setup GitHub Pages "gh-pages" branch as a subfolder within the "master" project on your local checkout - a step-by-step guide.

Intro

Setup GitHub Pages "gh-pages" branch as a subfolder within the "master" project on your local checkout.

IMPORTANT

If you plan on switching between different branches (e.g. git checkout master-experiment then revert back with git checkout master) you will loose your child folder from this tutorial (because it's in your .gitignore and is not part of your master branch).

@momania
momania / gist:858476
Created March 7, 2011 13:05
Akka AMQP Loadbalance
import akka.amqp.AMQP._
import akka.amqp._
import akka.actor._
import java.util.concurrent.{TimeUnit, CountDownLatch}
import util.Random
object LoadBalancingDemo {
def main(args: Array[String]) {
@m0wfo
m0wfo / gist:940422
Created April 25, 2011 12:10
Prüfer Sequence algorithm
(defn prufer
"Convert a labelled tree to a Prüfer Sequence."
([graph] (prufer graph []))
([graph prufer-sequence]
(loop [g graph p prufer-sequence]
(if (> (count g) 2) ; A Prüfer sequence is always of length n - 2
;v finds the lowest-valued leaf node
(let [v (apply min-key first (filter #(= 1 (count (last %))) g))]
; Remove the label's node key and occurrences in edge sets,
; then push its neighbour's label onto front of Prüfer sequence p.
@folone
folone / SCombinator.scala
Created June 30, 2011 07:19
Y-Combinator in Scala
/**
* <b>Fixed Point Combinator is:</b>
* Y = λf.(λx.f (x x)) (λx.f (x x))
*
* <b>Proof of correctness:</b>
* Y g = (λf . (λx . f (x x)) (λx . f (x x))) g (by definition of Y)
* = (λx . g (x x)) (λx . g (x x)) (β-reduction of λf: applied main function to g)
* = (λy . g (y y)) (λx . g (x x)) (α-conversion: renamed bound variable)
* = g ((λx . g (x x)) (λx . g (x x))) (β-reduction of λy: applied left function to right function)
* = g (Y g) (by second equality) [1]
@krasserm
krasserm / MonadTransformerExamples.scala
Created July 14, 2011 10:32
Scalaz 7 monad transformer examples
import scalaz._
import Scalaz._
object MonadTransformerExamples {
def main(args: Array[String]) = run
def run {
// ------------------------------------------------------
// Combined Option/Option
// ------------------------------------------------------
@zliuva
zliuva / gist:1084476
Last active July 31, 2023 21:32
A minimal Mach-o x64 executable for OS X
; A minimal Mach-o x64 executable for OS X (also see below Mountain Lion version)
;
; $ nasm -f bin -o tiny_hello tiny_hello.s
; $ chmod +x tiny_hello
; $ ./tiny_hello
; Hello World!
; $
; c.f.
; http://osxbook.com/blog/2009/03/15/crafting-a-tiny-mach-o-executable/ ( the original tiny mach-o executable )
@pazdera
pazdera / adapter.cpp
Created August 15, 2011 07:37
Example of `adapter' design pattern in C++
/*
* Example of `adapter' design pattern
* Copyright (C) 2011 Radek Pazdera
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
@9876691
9876691 / gist:1292881
Created October 17, 2011 15:35
Simple IRC connect
#include <iostream>
#include <string>
#include <sys/socket.h>
#include <sys/types.h>
#include <cstring>
#include <netdb.h>
using namespace std;
int main() {
@tonious
tonious / hash.c
Last active June 21, 2024 00:57
A quick hashtable implementation in c.
/* Read this comment first: https://gist.github.com/tonious/1377667#gistcomment-2277101
* 2017-12-05
*
* -- T.
*/
#define _XOPEN_SOURCE 500 /* Enable certain library functions (strdup) on linux. See feature_test_macros(7) */
#include <stdlib.h>
#include <stdio.h>