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 / gist:7c34b7744782e01a6170
Created March 13, 2016 05:59
The lesser-known Clojure de-structuring
(let [{elkn :extremely-long-key-name} {:extremely-long-key-name 42}]
(println elkn))
;=> 42
@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 / no-bugs.cljs
Created March 31, 2016 11:12
ClojureScript + core.async + Om + animation-cljs = WIN!
(defn no-bugs [{:keys [] :as data} owner {:keys []}]
(reify
om/IInitState
(init-state [_]
{:comm-ch (chan)
:obstacle {:x 50 :width 50 :height 50}
:animated {:x 10}})
om/IDidMount
(did-mount [_]
(let [{:keys [comm-ch]} (om/get-state owner)
@raspasov
raspasov / hush-product-schema.json
Last active May 28, 2016 04:36
Hush Product Schema - Sample 1
{
"name": "RB3183 Sunglasses 63 mm",
"categories": [
"unisex",
"eyewear"
],
"brand": "Ray Ban",
"description": "Made in US,Ray-Ban sizes refer to the width of one lens in millimeters,Lenses are prescription-ready (Rx-able)",
"external-product-id": "Either Globally Unique Identifier or Unique Identifier of the Product in Your System",
"original-price": 12750,
@raspasov
raspasov / hush-product-schema-2.json
Created May 28, 2016 04:27
Hush Product Schema - Sample 2
{
"name": "Soleil v2 Comfort Fun",
"categories": [
"womens",
"shoes",
"sneakers-&-athletic-shoes"
],
"brand": "Puma",
"description": "Dance-inspired sneaker, Synthetic leather uppers, Lightly padded tongue and collar",
"external-product-id": "Either Globally Unique Identifier or Unique Identifier of the Product in Your System",
@raspasov
raspasov / immutable-v-list.cljs
Last active March 14, 2017 10:22
VirtualizedList + Om.next
(ns immutable-v-list
"Example of React Native VirtualizedList from Om.next"
(:require [om.next :as om :refer-macros [defui]]))
(set! js/window.React (js/require "react"))
(set! js/window.ReactNative (js/require "react-native"))
(def ^js/window.ReactNative ReactNative js/window.ReactNative)
(defn create-element-no-auto-js
@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")
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 / 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)
@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))