Skip to content

Instantly share code, notes, and snippets.

View sshine's full-sized avatar
🦀

Simon Shine sshine

🦀
View GitHub Profile
@sshine
sshine / klassedelinger.sml
Created November 7, 2012 04:01
klassedelinger.sml
(* concatMap : ('a -> 'b list) -> 'a list -> 'b list
* Forklaring:
* f x = [y1,...,yn]
* map f xs = [[a1,...,an], [b1,...,bn], ..., [z1,...,zn]]
* concat (map f xs) = [a1,...,an,b1,...,bn,z1,...zn] *)
fun concatMap f xs = List.concat (map f xs)
(* foranNte x xss n: sætter x som det første element i den n'te liste i xss.
* Eks.: foranNte 0 [[1,2],[3,4],[5,6],[7,8]] 2 = [[1,2],[3,4],[0,5,6],[7,8]]
*)
@sshine
sshine / gist:3781152
Created September 25, 2012 10:56
xmobarrc
Config { font = "-*-Fixed-*-R-Normal-*-13-*-*-*-*-*-*-*"
, bgColor = "black"
, fgColor = "grey"
, position = Top
, commands = [
Run Cpu ["-L","5","-H","50","--normal","green","--high","red"] 10
, Run Memory ["-t","Mem: <usedratio>%"] 10
, Run Date "%a %b %_d %H:%M" "date" 10
, Run BatteryP ["BAT0"] ["-t","<acstatus><left>%","--",
"-O","<fc=green>+</fc>","-o","<fc=red>-</fc>",
@sshine
sshine / skabelon.tex
Created September 21, 2012 17:12
Skabelon til LaTeX-workshop
\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[danish]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\author{John Doe}
\title{... før nu og i fremtiden}
(defun select-next-window ()
"Switch to the next window"
(interactive)
(select-window (next-window)))
(defun select-previous-window ()
"Switch to the previous window"
(interactive)
(select-window (previous-window)))
@sshine
sshine / gist:3673388
Created September 8, 2012 10:47
tabs2spaces
>~:9-v
^ ,_$84v
^,,:,:,:*<
@sshine
sshine / gist:3609048
Created September 3, 2012 12:36
afrunding
fun afrund n =
let
val n' = Real.trunc (n * 125.0)
val kr = Real.fromInt (n' div 100)
val ore = Real.fromInt ((n' mod 100) div 25 * 25) / 100.0
in kr + ore end
(* Mads og Christians *)
fun moms n = real(round(n * 4.0 * 1.25 ))/4.0;
@sshine
sshine / particles.py
Created March 5, 2012 17:00
2D particle simulator with objects and steady attractors
#!/usr/bin/python
import math
import random
import sys
import os
import pygame
import time
class UnpreparedParticle(Exception):
pass
@sshine
sshine / gist:1540128
Created December 30, 2011 14:37
My first Scheme program!
(define (tabulate n f)
(define (helper m)
(if (= m n)
()
(cons (f m) (helper (+ m 1)))))
(helper 0))
(define (make-table x y fill)
(define table (make-vector x))
(tabulate x
@sshine
sshine / categories.php
Created December 15, 2011 15:00
Tree traversal in PHP
<?php
$recursive_array = array(
0 => array(
'name' => 'pets',
'category' => array(
0 => array(
'name' => 'cats',
'category' => array(
0 => array(
@sshine
sshine / cowsay.hs
Created November 22, 2011 00:18
Cowsay (Haskell)
import Data.String.Utils
cow :: String
cow = concatMap (++ "\n") [
" \\ ^__^",
" \\ (oo)\\_______",
" (__)\\ )\\/\\",
" ||----w |",
" || ||" ]