Skip to content

Instantly share code, notes, and snippets.

@kolja
kolja / kto.clj
Created September 8, 2024 12:15
Account data (csv) pretty printer
#!/usr/bin/env bb
(ns Konto
(:require [clojure.string :as str]
[babashka.process :refer [shell]]
[clojure.pprint :refer [cl-format]]
[babashka.cli :as cli]
[babashka.fs :as fs]
[clojure.data.csv :as csv]
[clojure.java.io :as io]))
@kolja
kolja / nextup.clj
Created August 1, 2024 08:47
wrapper for the remind command line calendar
#!/usr/bin/env bb
(require '[clojure.string :as str]
'[babashka.process :refer [shell process]]
'[clojure.tools.cli :refer [parse-opts]])
(def cli-opts [["-h" "--help" "Show help"]
["-y" "--year YEAR" "Year (default to current year)"]])
(defn usage [options-summary]
@kolja
kolja / md2typst
Last active August 15, 2024 08:20
transform markdown to typst and generate pdf
#!/usr/bin/env bb
; // this is minimal typst template, you could use with this script:
; #let conf(
; // the variables below *must* be defined in the yaml frontmatter of your markdown file
; (font, foo, bar),
; doc,
; ) = {
; // set the font in the yaml frontmatter of your markdown file
; set text(
@kolja
kolja / CreatePrefabFromSelection.cs
Created June 5, 2024 13:58
Unity: Create Prefab from Selection
// Drop this script in the Editor folder of your project
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System;
using System.Reflection;
using System.Linq;
using System.IO;
public class CreatePrefabWindow : EditorWindow
@kolja
kolja / fizzbuzz.js
Created January 20, 2023 11:57
JavaScript FizzBuzz
// first naive, straight-forward solution:
function divides(a,b) {
return a % b === 0;
}
for (i=1; i<20; i++) {
if (divides(i,3) && divides(i,5)) {
console.log("fizzbuzz");
} else if (divides(i,3)) {
@kolja
kolja / bookmark
Created June 28, 2020 08:36
babashka bookmark plugin for nnn
#!/usr/bin/env bb
; kolja (@01k) 2020
;
; usage:
;
; create a directory where you would like to keep your bookmarks.
; create an env variable NNN_BMDIR with the path to that directory (e.g. "~/.config/nnn/bookmarks")
; save this file in ~/.config/nnn/plugins as "bookmark" (for example)
;
@kolja
kolja / hack.css
Created April 8, 2020 11:12
aligning SVG bullet-image to <ul> list entries.
/* this is not the solution you are looking for. Move along */
ul {
list-style-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='30' height='40' viewBox='-1 -1 2 2'><circle transform='translate(0,-1.7)' r='1' /><circle transform='translate(0,0.95)' r='1' /></svg>");
line-height: 0.6rem;
}
@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 "
@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 / fashionworld.jpg
Last active February 7, 2019 13:49
Kolja's Fashion World
fashionworld.jpg