Skip to content

Instantly share code, notes, and snippets.

View raspasov's full-sized avatar
🏎️
If you want things, make them.

Rangel Spasov raspasov

🏎️
If you want things, make them.
View GitHub Profile
@raspasov
raspasov / core.clj
Last active March 20, 2023 22:21
Transducers interrupt
(transduce
(comp
(map-indexed (fn [idx item] [idx item]))
(map (fn [[idx item]]
(println "sending to space" idx)
[idx item])))
(fn
;;completing arity
([accum] accum)
;;reduce arity
@raspasov
raspasov / reanimated-v2-for-cljs.js
Created September 4, 2021 12:24
Reanimated v2 shim for CLJS
import React, {useImperativeHandle, useRef, forwardRef} from 'react';
import Animated, {
useSharedValue,
useAnimatedStyle,
withTiming,
withSpring
} from 'react-native-reanimated';
function Box(props, ref) {
const aRef = useRef();
@raspasov
raspasov / xf.clj
Created May 6, 2021 09:49
Count comment lines
(ns ss.experimental.comment-line-count
(:require [net.cgrand.xforms :as x]))
(defn count-comment-lines []
(let [source (slurp "/Users/raspasov/cpp")
lines (line-seq
(java.io.BufferedReader.
(java.io.StringReader. source)))]
(transduce
@raspasov
raspasov / CHEAT.md
Last active April 19, 2021 14:44
Clojure(Script) Cheat Sheet

Clojure(Script) Cheat Sheet

Start a ClojureScript Node REPL:

clj -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "RELEASE"}}}' -M -m cljs.repl.node

Reload Clojure(Script) namespace from the REPL

@raspasov
raspasov / nested-data-structure-traversal.cljs
Last active April 12, 2021 10:55
A solution to a poorly defined "problem" :)
(def sections
;convert to Clojure data
(js->clj
#js [
#js {
"title" "Getting started",
"reset_lesson_position" false,
"lessons" [
{"name" "Welcome"},
{"name" "Installation"}
@raspasov
raspasov / xp.clj
Last active January 7, 2021 09:50
core.async agents experiment
(ns scratch
(:require [clojure.core.async :as a]
[taoensso.timbre :as timbre]))
(def core-async-agent-state (atom 0))
(def core-async-agent-ch (a/chan 1))
@raspasov
raspasov / core-async-101.cljs
Created January 5, 2021 07:22
core.async 101
(comment
;This takes at most ~2000 ms to execute
(let [process-seq-of-channels
(fn [chans]
(a/go
(loop [chans chans]
(if-not (empty? chans)
(let [ch (first chans)
resp (a/<! ch)]
(println resp)
import React, {PropTypes, Component, useImperativeHandle, useRef, forwardRef} from 'react';
import Animated, {useSharedValue, useAnimatedStyle, withTiming, withSpring} from 'react-native-reanimated';
function Box(props, ref) {
const aRef = useRef();
useImperativeHandle(ref, function () {
return {
moveBox: function (globalY) {
@raspasov
raspasov / patch-metro-worker.cljs
Last active April 28, 2020 22:34
Patches metro's worker.js for :advanced compilation to work with React Native
;USAGE
;1. get https://github.com/planck-repl/planck
;2. run it from the project folder like this:
;plk patch-metro-worker.cljs
(require '[planck.core :refer [spit slurp]])
;Works with ReactNative 0.62
(def my-production-index-js-file-name "index.prod.js")