Skip to content

Instantly share code, notes, and snippets.

View stianeikeland's full-sized avatar

Stian Eikeland stianeikeland

View GitHub Profile
(def 🔟 10)
(def 🚲 cycle)
(def ✊ take)
(def 🏁 (🚲 [:🚕 :🚗 :🚚 :🚒 :🚐]))
(✊ 🔟 🏁)
require "formula"
class Flashrom < Formula
homepage "http://flashrom.org/"
url "http://download.flashrom.org/releases/flashrom-0.9.7.tar.bz2"
sha1 "d08b4073ea3ebf63f03c3e502f4291f50ef348ee"
head "svn://flashrom.org/flashrom/trunk", :using => :svn
depends_on 'libusb-compat'
;; Anything you type in here will be executed
;; immediately with the results shown on the
;; right.
(import [com.pi4j.wiringpi Spi])
(def reg {:no-op (byte 0x0)
:row-1 (byte 0x1)
:row-2 (byte 0x2)
:row-3 (byte 0x3)
@stianeikeland
stianeikeland / core.clj
Created April 10, 2014 07:56
Maxi yahtzee scoring - Bergen Coding Dojo - 10th of April - Stian and Anneli
(ns yathzee.core
(:require [clojure.set :refer :all]))
(defn- sum [list]
(reduce + list))
(defn score-singles [num roll]
(sum (filter #(= num %) roll)))
(def score-1s (partial score-singles 1))
;;; Kompiler og kjoer med:
;;; nasm -f elf64 -F stabs kake.asm && gcc -o kake kake.o && ./kake
global main
extern printf
segment .data
formatert db 'Svaret er: %u!', 0Ah, 0h
segment .text
(fact (let [c (chan)
_ (>!! c :hallo)]
(deref (future (<!! c)) 200 :timeout) => :hallo))
@stianeikeland
stianeikeland / csp-prime-sieve.clj
Created June 30, 2014 10:38
Concurrent prime sieve using core.async in clojure
;;; Concurrent prime sieve using core.async in clojure
(ns primesieve.core
(:require [clojure.core.async :as async :refer [go-loop chan >! <! <!! close! filter< to-chan]]))
(def bufsize 512)
(defn gen [upper-limit]
"Returns channel, puts numbers from 2 to upper-limit into channel"
(to-chan (range 2 upper-limit)))
@stianeikeland
stianeikeland / mirror.sh
Created July 3, 2014 15:58
ubuntu old mirrors
#!/bin/bash
sed -i "s/http:\/\/.*ubuntu.com\/ubuntu/http:\/\/old-releases.ubuntu.com\/ubuntu/g" /etc/apt/sources.list
@stianeikeland
stianeikeland / blackjack.hy
Last active August 29, 2015 14:07
blackjack kata in hy at bergen coding dojo
(require hy.contrib.loop)
(import [random [shuffle]])
(def ranks (+ (range 2 11) [:a :k :q :j]))
(def suits [:h :c :d :s])
;; OH MY IMPERATIVE GAAWD!
(def deck [])
(for [rank ranks
suit suits]
@stianeikeland
stianeikeland / variant.clj
Last active August 29, 2015 14:10
variant core.typed
(ns variants-playground.core
(:require [clojure.core.typed :as t :refer [cf defalias ann U Value Str HVec HMap]]
[clojure.core.match :refer [match]]))
(defmacro Variant [& lst]
`(U ~@(for [[tag & items] lst]
`(HVec [(Value ~tag)
(HMap :mandatory ~@items)]))))
(println (macroexpand '(Variant [:foo {:bar Str}])))