Skip to content

Instantly share code, notes, and snippets.

View dermesser's full-sized avatar
🐢
a bit of time :-)

Lewin Bormann dermesser

🐢
a bit of time :-)
View GitHub Profile
@dermesser
dermesser / test.c
Created February 13, 2012 17:07
Use of localtime()
# include <stdio.h>
# include <time.h>
# include <locale.h>
int main(void)
{
time_t currtime = time(NULL); // time_t time(time_t *timep)
struct tm *local, *gmt;
local = localtime(&currtime);
@dermesser
dermesser / .gitignore-latex
Last active December 10, 2015 01:48 — forked from kogakure/.gitignore
*.aux
*.glo
*.idx
*.log
*.toc
*.ist
*.acn
*.acr
*.alg
*.bbl
@dermesser
dermesser / downcode.sh
Created December 27, 2012 11:50
Little bash script to clean up file names of ogg files and transcode them to 64 kbit/s for my phone
#!/bin/bash
# Usage:
#
# Go to the directory you want to contain the transcoded files and
# call this script: $ downcode.sh /path/to/ogg/files/to/be/transcoded
# The transcoded ogg files containing the old tags are placed in $PWD.
# --> Spaces are replaced by underscores (_) in both the file names of the
# ogg files being transcoded and the new ogg files!
@dermesser
dermesser / gist:6145931
Last active December 20, 2015 14:19
Attendance tracking with pg/SaS in Haskell
{-# LANGUAGE OverloadedStrings #-}
import System.IO
import System.IO.Error
import System.Locale
import System.Exit
import Control.Monad
import Control.Exception
@dermesser
dermesser / dec2bin2dec.hs
Created August 7, 2013 18:46
Haskell code to convert decimal numbers to a digital representation ([Digital]) and vice versa.
-- Dec2Bin
--
data Digital = D1 | D0
instance Show Digital where
show D1 = "1"
show D0 = "0"
instance Eq Digital where
@dermesser
dermesser / PriorityTreeQueue.cpp
Last active January 1, 2016 08:29
Priority Queue implementation using binary searching trees: Minimum priority items can be found at the leftmost leaf, maximum priority items at the rightmost one. Should have insertion/lookup complexities of around `log n`.
/*
Compile this file using a C++11-compliant compiler!
*/
# include <iostream>
# include <string>
# include <vector>
@dermesser
dermesser / ParallelQuicksort.hs
Last active January 1, 2016 12:39
Compile: ghc --make -eventlog -threaded -rtsopts ParallelQuicksort.hs Execute: ./parqsort +RTS -s -l -N4 -H500M # (for example)
module Main where
import Control.Parallel.Strategies
import Data.List
-- Standard quicksort
qsort :: Ord a => [a] -> [a]
qsort [] = []
qsort (x:xs) = let smaller = [e | e <- xs, e <= x]
bigger = [e | e <- xs, e > x]
@dermesser
dermesser / CMakeLists.txt
Created January 4, 2014 10:58
Small one-bit array library.
project(libbitarray)
cmake_minimum_required(VERSION 2.8)
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -O3)
include_directories(.)
set(libsources
bitarray.c
)
@dermesser
dermesser / Url.hs
Last active August 29, 2015 13:56
A small URL parser, including URL-encoded arguments
module Url where
import Data.List
import Text.Parsec
import Text.Parsec.String
data Proto = HTTP | FTP
data URL = URL {
@dermesser
dermesser / libfcgi-example.c
Created July 3, 2014 11:14
In case anyone wants to see a multi-threaded FastCGI application written with the fcgiapp library.
# include <stdlib.h>
# include <stdio.h>
# include <sys/stat.h>
# include <pthread.h>
# include <fcgiapp.h>
const char* const sockpath = "/tmp/fcgicpp.sock";