Skip to content

Instantly share code, notes, and snippets.

View maacl's full-sized avatar

Martin Clausen maacl

View GitHub Profile
for (var i = 0; i < planets.length; i++) {
planets[i]=newPosition(planets[i], planets);
}
@maacl
maacl / core.clj
Last active January 29, 2023 07:07
Domain Modelling using Clojure
(ns pms.core
(:require [clojure.spec.alpha :as s]
[clojure.spec.gen.alpha :as gen]
[clojure.spec.test.alpha :as stest]))
(comment "This is a small experiment inspired by Oskar Wickströms
excellent work at
https://haskell-at-work.com/episodes/2018-01-19-domain-modelling-with-haskell-data-structures.html. I
wanted to see what would be involved in building the equivalent
functionality in reasonably ideomatic Clojure. It is also my first
@maacl
maacl / build.edn
Last active June 16, 2018 15:24
cljs webpack prosemirror
{:main hello-webpack.core
:output-to "out/main.js"
:output-dir "out"
:infer-externs true
:npm-deps false
:foreign-libs [{:file "dist/index_bundle.js"
:provides ["prosemirror-state"]
:global-exports {prosemirror-state ProseMirrorState}}]}
➜ build cmake ..
-- The C compiler identification is GNU 5.5.0
-- Check for working C compiler: /home/linuxbrew/.linuxbrew/bin/cc
-- Check for working C compiler: /home/linuxbrew/.linuxbrew/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1")
-- Looking for pthread.h
@maacl
maacl / brew.txt
Created July 19, 2018 08:10
mention of brew in build dir
tests/CMakeFiles/libgit2_clar.dir/flags.make:4:# compile C with /home/linuxbrew/.linuxbrew/bin/cc
tests/CMakeFiles/libgit2_clar.dir/link.txt:1:/home/linuxbrew/.linuxbrew/bin/cc -D_GNU_SOURCE -Wall -Wextra -fvisibility=hidden -fPIC -Wno-missing-field-initializers -Wstrict-aliasing -Wstrict-prototypes -Wdeclaration-after-statement -Wshift-count-overflow -Wno-unused-function -g -D_DEBUG -O0 -rdynamic CMakeFiles/libgit2_clar.dir/main.c.o CMakeFiles/libgit2_clar.dir/clar_libgit2.c.o CMakeFiles/libgit2_clar.dir/clar_libgit2_trace.c.o CMakeFiles/libgit2_clar.dir/clar_libgit2_timer.c.o CMakeFiles/libgit2_clar.dir/clar.c.o CMakeFiles/libgit2_clar.dir/apply/fromdiff.c.o CMakeFiles/libgit2_clar.dir/apply/fromfile.c.o CMakeFiles/libgit2_clar.dir/attr/file.c.o CMakeFiles/libgit2_clar.dir/attr/flags.c.o CMakeFiles/libgit2_clar.dir/attr/ignore.c.o CMakeFiles/libgit2_clar.dir/attr/lookup.c.o CMakeFiles/libgit2_clar.dir/attr/repo.c.o CMakeFiles/libgit2_clar.dir/blame/blame_helpers.c.o CMakeFiles/libgit2_clar.dir/blame/buffe
@maacl
maacl / Module1.xba
Created September 8, 2018 10:04
Index update macro
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<!--
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
@maacl
maacl / raycast2d.cljs
Created July 15, 2019 16:12
2d raycasting using Quil
(ns my.core
(:require [quil.core :as q :include-macros true]
[quil.middleware :as m]))
(defn cast [{[x1 y1] :a [x2 y2] :b} {[x3 y3] :pos [x4 y4] :dir}]
(let [x4 (+ x3 x4)
y4 (+ y3 y4)
den (- (* (- x1 x2) (- y3 y4))
(* (- y1 y2) (- x3 x4)))]
(if-not (= 0 den)
@maacl
maacl / ray-trace.cljs
Created August 7, 2019 23:25
Simpel ray tracer in cljs/quil.
;; Converted from this: http://www.ulisp.com/list?2O52
(ns ray.core
(:require [quil.core :as q :include-macros true]
[quil.middleware :as m]))
(defn col [r g b]
[r g b])
(defn pt [x y z]
[x y z])
(defn v [x y z]
@maacl
maacl / core.clj
Last active July 19, 2020 13:58
r/fold parallelism
(ns csv2summap.core
(:require [clojure.data.csv :as csv]
[clojure.java.io :as io]
[clojure.core.reducers :as r]))
(with-open [writer (io/writer "numbers.csv")]
(csv/write-csv
writer
(take 1000000 (repeatedly #(vector (char (+ 65 (rand-int 26))) (rand-int 1000))))))
http://quil.info/sketches/show/27fb47d5400dee4928303046731ff47c3b460539568af20665dc8e43fffedc07