Skip to content

Instantly share code, notes, and snippets.

View callerobertsson's full-sized avatar
Converting coffee to code

Calle Robertsson callerobertsson

Converting coffee to code
View GitHub Profile
@callerobertsson
callerobertsson / jsonformat.js
Created May 26, 2015 06:56
Javascript: JSON Formatter
// jsonformat.js
// a simple script that format JSON data in a more readable way.
// by Calle Robertsson, calle@upset.se, 2015.
var fs = require('fs');
var filename = process.argv[2];
if (!filename) {
throw new Error('Missing command line argument for file name.');
}
@callerobertsson
callerobertsson / kanal.go
Created June 20, 2015 09:51
Golang: Playing with a queue channel
package main
import (
"bufio"
"fmt"
"math/rand"
"os"
"strconv"
"time"
)
@callerobertsson
callerobertsson / gopastebin.go
Last active August 29, 2015 14:27
Golang: Command line wrapper for posting to pastebin.com
package main
import (
"flag"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"os"
"strconv"
@callerobertsson
callerobertsson / fibonacci.go
Last active January 14, 2022 15:49
Golang: Fibonacci Big Number
package main
import (
"fmt"
"math/big"
)
func main() {
for i := 1; i <= 10; i++ {
@callerobertsson
callerobertsson / fibonacci.hs
Last active November 22, 2017 17:00
Haskell: Fibonacci Big Number
module Main where
main = do
print $ map fibN' [1..10]
print $ fibN' 1001
print $ length $ show $ fibN' 500000
fibN' 1 = 0
fibN' 2 = 1
fibN' n = iter 0 1 n where
@callerobertsson
callerobertsson / main.go
Last active January 31, 2022 11:53
Golang: Stable sort on priority and order
package main
import (
"fmt"
"sort"
)
// Item has a priority and an order
type Item struct {
Prio int