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 / cljs-animate.cljs
Created March 18, 2016 08:54
ClojureScript Animation Library
(ns my-project.cljs-animate
(:require-macros [cljs.core.async.macros :refer [go]])
(:require [cljs.core.async :refer [offer! put! promise-chan chan <! >! timeout alts! chan timeout dropping-buffer sliding-buffer]]))
;THIS IS A COPY/PASTE of https://github.com/gstamp/tween-clj
;TODO make tween-clj a ClojureScript lib (easy)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Transition types
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@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) {