Skip to content

Instantly share code, notes, and snippets.

View roman01la's full-sized avatar
🇺🇦

Roman Liutikov roman01la

🇺🇦
View GitHub Profile
@roman01la
roman01la / day02.clj
Created December 3, 2019 00:57
AoC 2019, Day 2
(defn execute-instruction! [opcode input offset]
(let [p1 (nth input (+ 1 offset))
p2 (nth input (+ 2 offset))
p3 (nth input (+ 3 offset))
op (case opcode
1 +
2 *)]
(->> (op (nth input p1) (nth input p2))
(assoc! input p3))))
@roman01la
roman01la / day01.clj
Created December 1, 2019 09:52
AoC 2019, Day 1
(def input
(->> (clojure.string/split (slurp "src/day01_input") #"\s")
(map read-string)))
(defn calc-fuel [m]
(-> m (/ 3) int (- 2)))
(defn solve-day1-p1 [input]
(->> (map calc-fuel input)
(reduce +)))
(ns test.core)
(defn add [^i32 a ^i32 b]
(let [x 1
y 2]
(if (= a b)
(+ x y)
(+ a b))))
(defn main []
@roman01la
roman01la / adapton.ts
Created September 26, 2019 13:45
Adapton
type Thunk = Function;
type Result = any;
class Adapton {
thunk: Thunk;
result: Result;
sub: Set<Adapton>;
sup: Set<Adapton>;
isClean: boolean;
[data-testid="sidebarColumn"] {
display: none;
}
[data-testid="primaryColumn"] {
max-width: 1000px;
}
[data-testid="primaryColumn"] > div:first-child > div:nth-child(3) {
max-width: 800px;
}
[aria-label=Primary] > a > div > div:nth-child(2),
createStore({
dropTargetIDToBoxID: {
"drop1": "box1"
"drop2": "box2"
"drop3": null
},
boxes: {
"box1": {x:0, y: 0},
"box2": {x:100, y: 100},
}
{:share-link-id #uuid "7fe2a3a4-6b2c-442b-ba59-d90abed2d700",
:updated-at #inst "2019-05-24T16:04:53.297-00:00",
:owned? false,
:title "I like trams too",
:document-id #uuid "1aa3ef49-e16a-4c1e-b034-3b3ac4d006a3",
:preview-slide
{:entity-type :slide,
:theme
{:entity-type :style,
:name "Pitch Default",
(ns css.macros
(:require [clojure.string :as string]))
(defn static? [s]
(or (string? s)
(keyword? s)
(number? s)))
(def px-vals
#{:font-size :top :left :right :bottom :width :height
(defonce db (atom {}))
(defn sub [f]
(let [state (uix/state #(f @db))]
(uix/layout-effect!
(fn []
(let [id (random-uuid)]
(add-watch db id (fn [_ _ o n]
(let [of (f o)
nf (f n)]
(defn use-ratom [r]
(let [[state force-update] (js/React.useState @r)]
(js/React.useLayoutEffect
(fn []
(let [id (random-uuid)]
(add-watch r id (fn [_ _ o n]
(when (not= o n)
(force-update n))))
#(remove-watch r id)))
#js [r])