Skip to content

Instantly share code, notes, and snippets.

View djblue's full-sized avatar

Chris Badahdah djblue

View GitHub Profile
@Yogsther
Yogsther / hbomax_ultrawide.json
Created January 25, 2022 20:42
21:9 support for HBO MAX (Ultrawide aspect ratio)
{"userCSSoptions":{"theme":"default","font":"font%3A%2016px%2F20px%20monospace","width":"400","height":"300","dock":"right","opacity":"100"},"userCSSstyles":[{"site":"play.hbomax.com","styles":"video{\n height: calc(100vh * 1.238) !important;\n top: calc(-100vh * 0.238/2) !important;\n}","toggle":1}]}
@borkdude
borkdude / gh-releases.rb
Last active September 27, 2021 16:14
Brew install babashka script
# install with brew reinstall --build-from-source ./gh-releases.rb
# set GITHUB_TOKEN to a personal Github token
# then run: gh-releases list :org babashka :repo :babashka
class GhReleases < Formula
desc ""
homepage ""
license ""
url "file:///dev/null"
sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
@borkdude
borkdude / find-var.clj
Last active January 20, 2023 09:13
Babashka script to find var usages in current project
#!/usr/bin/env bb
;; usage:
;; $ find-var.clj babashka.main/main src:test
;; example output:
;; src/babashka/main.clj:672:32
;; src/babashka/main.clj:673:22
;; src/babashka/main.clj:676:28
;; test/babashka/test_utils.clj:31:59
@borkdude
borkdude / logger.clj
Last active April 27, 2021 20:23
Simple logger that works in bb
(ns logger)
(defmacro log [& msgs]
(let [m (meta &form)
_ns (ns-name *ns*) ;; can also be used for logging
file *file*]
`(binding [*out* *err*] ;; or bind to (io/writer log-file)
(println (str ~file ":"
~(:line m) ":"
~(:column m))
@borkdude
borkdude / repl.clj
Last active March 4, 2021 22:44
REPL session of babashka and sci internals @ London Clojurians December 2020
(ns ldnclj.repl
(:require [babashka.main :as bb]
[cheshire.core :as json]
[edamame.core :as e]
[sci.core :as sci]
[sci.impl.analyzer :as ana]
[sci.impl.interop :as interop]
[sci.impl.interpreter :as i]
[sci.impl.parser :as p]))
@mfikes
mfikes / keys-vals.md
Last active November 23, 2020 13:27

The following works in Clojure:

(keys (filter (comp odd? val) {:a 1 :b 2 :c 3}))

The docstrings for keys and vals don't indicate that you can do this. Is this accidential or intentional?

I vaguely recall Alex Miller indicating at some point that this capability was deemed useful and is intentionally allowed. Yes, this is an appeal to authority, but nevertheless, it makes a fairly convincing argument.

"""
A super simple Jupyter cell magic that writes the cell to `main.cpp` or
specified file, compiles the file using g++ and executes the code using
`./a.out`
Limitations: the cell must be a complete C++ program.
"""
from IPython.core.magic import (register_line_magic,
register_cell_magic)
import subprocess
@mauricioszabo
mauricioszabo / with_code.clj
Last active April 18, 2022 04:25
Open Socket REPL on CLR or Clojerl
#Clojerl
./bin/clje \
-e "(do (require 'clojure.core.server) \
(clojure.core.server/start-server \
{:name \"socket-repl\" \
:port 4444 \
:accept 'clojure.main/repl \
:address \"localhost\"}))" -r
#CLR
@borkdude
borkdude / http-socket-server.clj
Last active May 3, 2021 22:59 — forked from souenzzo/http-socket-server.clj
tiny http server via java sockets in babashka
#!/usr/bin/env bb
(import (java.net ServerSocket))
(require '[clojure.string :as string] '[clojure.java.io :as io])
(with-open [server-socket (new ServerSocket 8080)
client-socket (.accept server-socket)]
(loop []
(let [out (io/writer (.getOutputStream client-socket))
in (io/reader (.getInputStream client-socket))
@yogthos
yogthos / core.cljs
Last active October 9, 2024 04:11
Gjs ClojureScript example
(ns gjs-example.core)
(defn main []
(set! (-> js/imports .-gi .-versions .-Gtk) "3.0")
(let [Gtk (doto (-> js/imports .-gi .-Gtk) (.init nil))
window (Gtk.Window.
(clj->js
{:type (-> Gtk .-WindowType .-TOPLEVEL)
:title "A default title"
:default_width 300