This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Parts of my .vimrc which might be relevant to Clojure users. | |
" Src: https://raw.githubusercontent.com/Deraen/dotfiles/master/.vimrc | |
" NeoBundle is a Vim package manager | |
" Check https://github.com/Shougo/neobundle.vim for installation | |
" Autocomplete - https://github.com/Valloric/YouCompleteMe | |
NeoBundle 'Shougo/vimproc', {'build': {'unix': 'make'}} | |
NeoBundle 'Valloric/YouCompleteMe' | |
" Clojure syntax highlight |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns working-with-data | |
(:require [working-with-data.data :refer [participants]])) | |
;; Futu training, 5.6.2014 | |
;; RECAP | |
(def a {:name "Juho"}) | |
;; assoc - return a new map | |
(assoc a :age 24) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns foobar.daemon | |
(:require [foobar.main :as main]) | |
(:import [org.apache.commons.daemon Daemon DaemonContext]) | |
(:gen-class | |
:implements [org.apache.commons.daemon.Daemon])) | |
(def state (atom nil)) | |
;; Daemon implementation | |
(defn -init [this ^DaemonContext context]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns working-with-data | |
(:require [metosin.dataset.pizzas :refer [pizzas]])) | |
(conj pizzas {:name "Speciale"}) | |
; v1 | |
(filter (fn [pizza] | |
(if (< (get pizza :price) 8) | |
true)) | |
pizzas) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn mrg [[x & xrest :as X] [y & yrest :as Y] R] | |
(if (and X Y) | |
(if (<= x y) | |
(recur xrest Y (conj R x)) | |
(recur X yrest (conj R y))) | |
(concat R X Y))) | |
(defn mrgsrt [X] | |
(if (> (count X) 1) | |
(let [[left right] (split-at (/ (count X) 2) X)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn outrun-2 [pyramid] | |
(->> pyramid | |
(reduce | |
(fn [previous line] | |
(mapv (fn [this i] | |
(let [left (get previous (dec i) 0) | |
right (get previous i 0)] | |
(+ this (max left right)))) | |
line | |
(range)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns reaktor-outrun.core | |
(:require [nio.core :as nio] | |
[clojure.java.io :as io] | |
[hiphip.int :as hh]) | |
(:gen-class :main true)) | |
(set! *warn-on-reflection* true) | |
(set! *unchecked-math* true) | |
;; http://reaktor.fi/blog/fast-track-osa-kolme-koodaa-out-run-lempikielellasi/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns foobar.components | |
(:require [com.stuartsierra.component :as component] | |
[compojure.api.sweet :refer :all])) | |
(defmethod compojure.api.meta/restructure-param :components | |
[_ components acc] | |
(update-in acc [:letks] into [components `(::components ~'+compojure-api-request+)])) | |
(defn wrap-components [handler components] | |
(fn [req] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env runhaskell | |
import System.IO | |
import Control.Monad | |
import qualified Data.Text as T | |
splitLines :: String -> [String] | |
splitLines s = map T.unpack $ T.splitOn (T.pack ",") $ T.pack s | |
readNumbers :: [String] -> [Int] | |
readNumbers = map (\x -> read x :: Int) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn debounce | |
"Creates a channel which will change put a new value to the output channel | |
after timeout has passed. Each value change resets the timeout. If value | |
changes more frequently only the latest value is put out. | |
When input channel closes, the output channel is closed." | |
[in ms] | |
(let [out (chan)] | |
(go-loop [last-val nil] | |
(let [val (if (nil? last-val) (<! in) last-val) |