Skip to content

Instantly share code, notes, and snippets.

-----BEGIN PGP MESSAGE-----
Version: GnuPG/MacGPG2 v2.0.22 (Darwin)
Comment: GPGTools - https://gpgtools.org
owGbwMvMwMV46WzJSv/3XXsZTx94lsQQYin7oFopKT+lUsmqWik5JzM1rwTEykvM
TVWyUspOrUxKLE7Vy8xXyMtPSdXLKlaAqtFRKkstKs7MzwOqMtAz1zNSqtUBKQdp
TsvMS08tKijKBJmlZGJsapJskmaSZGZkYmRqZGBoaWmcapZslmKUnGJukmhpkpaa
ZpGYlAI0MiO/uATFViWwmfGZKUBRFyNnF3MTR0sTN1c3C0cnF6BcKVgiydzQIikx
0dQkycLMPCnJ0MzIwMQ8LSU5xTLZINnUwACksDi1COal/JysRJBjgUJlmcmpSL5N
zyzJKE3CobyksgDEL09NiofqjE/KzEsBehU5LAyBKpNLMkFaDU0MjQ2MLI0NDXSU
@kolja
kolja / add.js
Created October 26, 2014 12:44
Add Numbers by passing them to the same function in succession
var add = function(x) {
add.sum = add.sum || 0;
add.sum += x;
add.valueOf = function() {
return add.sum;
};
return add;
};
@kolja
kolja / daily.coffee
Last active December 18, 2015 09:59
cli to read and write "diary entries" to CouchDB
#!/usr/local/bin/coffee
nopt = require 'nopt'
nano = require('nano')('http://localhost:5984/dailies')
optionDef =
"u": String # user
"m": String # Message
"l": Number
"t": [String, Array] # Tags
// ==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
@kolja
kolja / sphere.cljs
Last active May 22, 2017 11:08
create a sphere from cubes
#!/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))
@kolja
kolja / balanced.cljs
Last active September 20, 2017 14:18
find out if a string with parens is balanced
#!/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)))
@kolja
kolja / primes.clj
Created November 9, 2017 18:21
calculate prime numbers and prime factors with clojure
(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))))))
@kolja
kolja / fashionworld.jpg
Last active February 7, 2019 13:49
Kolja's Fashion World
fashionworld.jpg
@kolja
kolja / split.js
Created February 8, 2019 13:44
split Arrays into chunks with Javascript
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 ] ]
@kolja
kolja / sub.cljs
Created January 25, 2020 14:33
Subtitle Editor
#!/usr/bin/env bash
"exec" "plk" "-Sdeps" "{:deps {org.clojure/tools.cli {:mvn/version \"0.4.2\"}}}" "-Ksf" "$0" "$@"
(ns subtitles.core
(:require
[planck.http :as http]
[planck.core :as core]
[clojure.tools.cli :refer [parse-opts]]
[clojure.string :as s]))
(def help "