Skip to content

Instantly share code, notes, and snippets.

View andreivolt's full-sized avatar

Andrei Volt andreivolt

View GitHub Profile
@andreivolt
andreivolt / pbpaste-html.swift
Last active March 26, 2024 15:46 — forked from eruffaldi/pbpaste-html.swift
pbpaste html OSX
// xcrun -sdk macosx swiftc pbpaste.swift -o pbpaste-html
// from: http://stackoverflow.com/questions/17217450/how-to-get-html-data-out-of-of-the-os-x-pasteboard-clipboard
import Cocoa
let type = NSPasteboard.PasteboardType.html // PNG for image
if let string = NSPasteboard.general.string(forType: type) {
print(string)
} else {
print("Could not find string data of type '\(type)' on the system pasteboard")
exit(1)
}
@andreivolt
andreivolt / json2nix
Last active February 24, 2024 19:53 — forked from Scoder12/json2nix.py
Converts JSON objects into nix (hackishly).
#!/usr/bin/env python3
"""Converts JSON objects into nix (hackishly)."""
import sys
import json
import re
INDENT = " " * 2
@andreivolt
andreivolt / .gitignore
Created February 23, 2024 15:22 — forked from punchagan/.gitignore
Zoom Meetings Command Line
/.mypy_cache/
/.envrc
@andreivolt
andreivolt / convert.clj
Created February 23, 2024 00:19 — forked from KGOH/convert.clj
convert.clj -- babashka edn/json/yaml to edn/json/yaml converter
#!/usr/bin/env bb
;; convert.clj -- babashka edn/json/yaml to edn/json/yaml converter
;; Author: github.com/KGOH/
;; Source: gist.github.com/KGOH/50c0f66022fea2ac173518a143238058
;; Version: 2020.4
; Usage example:
; In Emacs: i.imgur.com/TIEDmga.mp4
; $ convert.clj edn <<< '{"foo": "bar"}'
; {:foo "bar"}
@andreivolt
andreivolt / track
Last active January 20, 2022 20:01
track shipments with Aftership
#!/usr/bin/env bash
jo direct_trackings=$(jo -a $(jo tracking_number=$1)) \
| http https://track.aftership.com/api/v2/direct-trackings/batch \
| jq -r '
.data.direct_trackings
| first
| .tracking.checkpoints[]
| [
(
#! /usr/bin/env nix-shell
#! nix-shell -i bb -p graalvm11-ce babashka clojure
(require '[clojure.java.io :as io]
'[clojure.java.shell :refer [sh]]
'[cheshire.core :as json] ; only for eval in editor
'[clojure.edn :as edn]
'[clojure.string :as s]
'[clojure.tools.cli :refer [parse-opts]])
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p graalvm11-ce babashka clojure jo
usage() {
cat <<EOF
build native binaries for Clojure using GraalVM
Usage: ${0##*/} extra_deps entrypoint java_reflection_classes
Example: ${0##*/} 'org.clojure/tools.deps.alpha {:mvn/version "0.12.1003"}' find-deps.core java.io.PushbackReader java.io.OutputStreamWriter
EOF
jo \
input=$(jo text="$*") \
voice=$(
jo \
languageCode=en-us \
name=en-US-Wavenet-C \
ssmlGender=FEMALE) \
audioConfig=$(jo audioEncoding=OGG_OPUS) \
| http https://texttospeech.googleapis.com/v1beta1/text:synthesize key==$GCLOUD_API_KEY \
| jq -r .audioContent \
@andreivolt
andreivolt / map-to-html.clj
Created August 5, 2021 21:04 — forked from semperos/map-to-html.clj
Function using hiccup to print a Clojure map as a "nested" HTML list.
(def example-map
{:a "foo" :b "bar" :other-stuff
{:item-1 ["hello" "clojure"],
:item-2 ["hello" "hiccup"],
:another-map
{:x "foo" :y "bar" :z "baz"}}
:c "wowza sauce"})
(defn map-to-html-list
"Clojure map to nested HTML list. Optional list-type and wrapper params taken as keywords hiccup understands, and optional sep parameter for the string to show key-value associations"
@andreivolt
andreivolt / datomic-edn-handlers.clj
Created August 5, 2021 18:21 — forked from favila/datomic-edn-handlers.clj
Utilities for making it easier to read edn files. Also includes tag readers that datomic uses.
(ns favila.read-edn.tag-readers
"Common tag-reader maps for edn."
(:require datomic.db
datomic.function
datomic.codec)
(:import java.net.URI))
(defmethod print-method URI [^URI x ^Writer w]
(doto w
(.write "#uri ")