Skip to content

Instantly share code, notes, and snippets.

Kolja kolja

Block or report user

Report or block kolja

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kolja
kolja / split.js
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 ] ]
@kolja
kolja / primes.clj
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))))))
@kolja
kolja / balanced.cljs
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)))
@kolja
kolja / sphere.cljs
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))
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
@kolja
kolja / add.js
Created Oct 26, 2014
Add Numbers by passing them to the same function in succession
View add.js
var add = function(x) {
add.sum = add.sum || 0;
add.sum += x;
add.valueOf = function() {
return add.sum;
};
return add;
};
View keybase proof
-----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 / daily.coffee
Last active Dec 18, 2015
cli to read and write "diary entries" to CouchDB
View daily.coffee
#!/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
You can’t perform that action at this time.