This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this is a parser for a language described in this tweet: https://twitter.com/msimoni/status/1721647625294782972 | |
const LPAR = 40 | |
const RPAR = 41 | |
const isWord = cp => 32 < cp && cp !== LPAR && cp !== RPAR | |
export const parse = inputString => { | |
const warnings = [] | |
const topLevelArray = [] | |
let currentArray = topLevelArray |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
❯ ollama run llama2-uncensored | |
>>> hi | |
What can you tell me about the latest technology in the world of artificial | |
intelligence? | |
>>> I though I asked the questions? | |
You're right, my apologies. The latest technology in the field of artificial | |
intelligence is currently focused on creating systems that can perform complex | |
tasks such as language translation, image recognition, and even autonomous | |
driving. These advancements are made possible by deep learning algorithms and |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Outer { | |
static final int staticFinalConstant = 42; | |
class Inner { | |
public int field = staticFinalConstant; | |
} | |
static void m() { | |
new Inner(); // error: non-static variable this cannot be referenced from a static context | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns logic | |
(:refer-clojure :exclude [==]) | |
(:require [clojure.core.logic :refer :all]) | |
(:require [clojure.core.logic.fd :as fd])) | |
;; mostly stolen from https://mattsenior.com/2014/02/using-clojures-core-logic-to-solve-simple-number-puzzles | |
(run* [q] | |
;; Create some new logic vars (lvars) for us to use in our rules | |
(fresh [v00 v01 v02 v03 v04 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bb | |
(ns clone | |
"clones a git repo to a path given by its url and opens a new shell at that path | |
clone.clj https://github.com/babashka/sci will clone to ~/github.com/babashka/sci" | |
(:require | |
[clojure.java.io :as io] | |
[clojure.string :as str] | |
[babashka.fs :as fs] | |
[babashka.process :refer [process check shell]])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; most of this code is copied from a source that used an older version of asmble, here we use 0.4.0 | |
;; unfortunately I cannot find the original so I apologise for the missing reference | |
;; {:deps | |
;; {com.github.cretz.asmble/asmble-compiler {:mvn/version "0.4.0"}}} | |
(ns asmble-fun | |
(:require [clojure.reflect :as r]) | |
(:import [asmble.cli Translate] | |
[asmble.run.jvm ScriptContext ExceptionTranslator | |
ModuleBuilder$Compiled |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; some surprises found while learning Clojure | |
;; min is for numbers | |
(min #inst "2018" #inst "2019") ; Execution error (ClassCastException) at clojure-test.core/eval8469 (form-init524028722621051551.clj:2589) . | |
; java.util.Date cannot be cast to java.lang.Number | |
;; macros are not values | |
(apply or (list false true)) ; Syntax error compiling at (Untitled-1:2:1). | |
; Can't take value of a macro: #'clojure.core/or |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface I<TP> { | |
fun TP.func() | |
} | |
class Dummy | |
class Implementer : I<Dummy> { | |
override fun Dummy.func() { | |
println(this) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; heavily inspired by Mariano Guerra | |
;; http://marianoguerra.org/posts/download-frontend-generated-data-to-a-file-with-clojurescript.html | |
(defn download-blob [file-name blob] | |
(let [object-url (js/URL.createObjectURL blob) | |
anchor-element | |
(doto (js/document.createElement "a") | |
(-> .-href (set! object-url)) | |
(-> .-download (set! file-name)))] | |
(.appendChild (.-body js/document) anchor-element) | |
(.click anchor-element) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn index-of-safe | |
"Return index of value (string or char) in s, optionally searching | |
forward from from-index. Return nil if value not found. | |
Works around https://bugs.openjdk.java.net/browse/JDK-8027640 | |
so the returned index is always greater equal to from-index. | |
This also works around JavaScript's similar behavior." | |
[s value from-index] | |
(if (< (count s) from-index) | |
nil | |
(clojure.string/index-of s value from-index))) |
NewerOlder