Instantly share code, notes, and snippets.

# Koljakolja

• Sort options
Created Feb 8, 2019
split Arrays into chunks with Javascript
View split.js
 const split = (arr, fn) => arr.reduce(([first, ...rest],el) => fn(el) ? first.length ? [[], first, ...rest] : [[], ...rest] : first.length ? [[...first, el], ...rest] : [[el], ...rest] , [[]]).reverse() const a = [...Array(12).keys()] split(a, x => !(x%5)) // [ [ 1, 2, 3, 4 ], [ 6, 7, 8, 9 ], [ 11 ] ]
Last active Feb 7, 2019
Kolja's Fashion World
Created Nov 9, 2017
calculate prime numbers and prime factors with clojure
View primes.clj
 (ns primes.core) (defn- primes "returns a lazy list of prime numbers via the sieve of eratosthenes" ([] (primes (iterate inc 2))) ([[head & tail]] (cons head (lazy-seq (primes (remove #(and (not= % head) (zero? (mod % head))) tail))))))
Last active Sep 20, 2017
find out if a string with parens is balanced
View balanced.cljs
 #!/usr/local/bin/lumo (ns balanced.core (:require [lumo.core :refer [*command-line-args*]] [clojure.string :refer [join]])) (defn is-pair? [ch1 ch2] (let [pairs {"(" ")" "[" "]" "{" "}"}] (= (get pairs ch1) ch2)))
Last active May 22, 2017
create a sphere from cubes
View sphere.cljs
 #!/usr/local/bin/lumo (ns sphere.core (:require [lumo.core :refer [*command-line-args*]] [clojure.string :refer [join]] [cljs.reader :refer [read-string]])) (defn sqr [n] (* n n)) (defn sqrt [n] (.sqrt js/Math n)) (defn cbrt [n] (.cbrt js/Math n)) (defn abs [n] (.abs js/Math n))
Created Aug 5, 2016
View gist:23e73cb4eacbc4548cb43eea48d1d48e
 // ==UserScript== // @name aws-login // @source // @downloadURL // @version 0.1.0 // @description login to AWS // @author kolja // @include *://signin.aws.amazon.com/saml // @run-at document-idle // @grant none
Created Oct 26, 2014
Add Numbers by passing them to the same function in succession