Skip to content

Instantly share code, notes, and snippets.

@tkocmathla
tkocmathla / opencode.sh
Last active January 27, 2026 07:19
Opencode bubblewrap sandbox
#!/bin/bash
WORKSPACES=(
"$HOME/code"
)
WORKSPACE_BINDS=()
for ws in "${WORKSPACES[@]}"; do
if [ -d "$ws" ]; then
WORKSPACE_BINDS+=(--bind "$ws" "$ws")
@tkocmathla
tkocmathla / sqlserver.clj
Last active October 17, 2018 16:53
Connecting to SQL Server using Clojure on Linux
;; add the following to :dependencies in project.clj:
;; [org.clojure/java.jdbc "0.7.6"]
;; [com.microsoft.sqlserver/mssql-jdbc "6.4.0.jre8"]
(require '[clojure.java.jdbc :as jdbc])
(def db-spec
{:classname "com.microsoft.jdbc.sqlserver.SQLServerDriver"
:subprotocol "sqlserver"
:subname "//sql-server-hostname;integratedSecurity=true;authenticationScheme=JavaKerberos"})
@tkocmathla
tkocmathla / wat.clj
Created September 26, 2017 19:13
Clojure wat
user=> :0
:0
user=> ::0
:user/0
user=> (read-string ":0")
:0
user=> (clojure.edn/read-string ":0")
:0
user=> (read-string "::0")
:user/0
@tkocmathla
tkocmathla / gist:02413378c72b115c816402f6a9566562
Last active August 31, 2017 21:38
Longest common prefix
(defn longest-common-prefix
"Returns the longest common prefix among xs, all of which must be seqable"
[& xs]
(->> xs
(apply map (fn [f & r] (when (apply = f r) f)))
(take-while identity)))
@tkocmathla
tkocmathla / core.clj
Last active June 5, 2017 02:24
Parser for Weka RandomForest trees (as output by -print option)
(ns weka-rf-parser.core
(:require
[clojure.java.io :as io]
[clojure.pprint :as pp]
[clojure.string :as string]
[clojure.zip :as zip]
[clj-ml.classifiers :as ml-cls]
[clj-ml.data :as ml-data]
[clj-ml.io :as ml-io])
(:import [weka.classifiers.trees RandomForest]))