Skip to content

Instantly share code, notes, and snippets.

View wilkerlucio's full-sized avatar

Wilker Lúcio wilkerlucio

View GitHub Profile
@wilkerlucio
wilkerlucio / specter-walk-keys.clj
Last active June 2, 2017 14:28
Specter - walk map keys
(def data
{:person/name "Bla"
:person/child {:child/something "other"
:child/bla {:subchild/entry "blabla"}}})
(def MapWalker
(sp/recursive-path [] p
(sp/if-path map?
(sp/continue-then-stay sp/MAP-VALS p))))
(om/defui ^:once BasicChannelView
static om/IQuery
(query [_] [:channel/id {:channel/snippet [:channel/title]}]))
(om/defui ^:once ComplexChannelView
static om/IQuery
(query [_] [:channel/id
{:channel/snippet
[:channel/title
{:channel/thumbnails
[org.clojure/clojure "1.9.0-alpha14"]
[org.clojure/clojurescript "1.9.494"]
[org.omcljs/om "1.0.0-alpha48"]
[clj-http "3.4.1"]
[cheshire "5.7.0"]
[camel-snake-kebab "0.4.0"]
@wilkerlucio
wilkerlucio / example.cljs
Created March 15, 2017 22:42
Lumo with container depencies
'{:dependencies [[org.clojure/core.async "0.2.395"]]
:node-dependencies [[request "2.81.0"]]}
(ns script.example
(:require [cljs.nodejs :as node]))
(def fs (node/require "fs"))
(def request (node/require "request"))
[{[:video/by-id "XHGKIzCcVa0"]
[{:video/snippet
[:video/title
:video/description
:video/published-at
{:video/channel
[{:channel/snippet
[:channel/title
{:channel/thumbnails
@wilkerlucio
wilkerlucio / natural-sort.clj
Last active May 18, 2022 14:16
Alphabetical/Natural sorting in Clojure/Clojurescript
(ns util.natural-sorting
(:refer-clojure :exclude [sort sort-by])
(:require [clojure.string]))
(defn parse-int [s]
#?(:clj (Long/parseLong s)
:cljs (js/parseInt s)))
(defn vector-compare [[value1 & rest1] [value2 & rest2]]
(let [result (compare value1 value2)]
@wilkerlucio
wilkerlucio / readers_notation.clj
Last active November 12, 2016 05:02
readers notation
(s/def ::reader-map (s/map-of keyword? ::reader))
(s/def ::reader-seq (s/coll-of ::reader :kind vector?))
(s/def ::reader-fn (s/fspec :args (s/cat :env map?)
:ret any?))
(s/def ::reader
(s/or :fn ::reader-fn
:map ::reader-map
:list ::reader-seq))
;; this works under normal compilation
;; on advanced it fails with: https://www.dropbox.com/s/krf7c38bwykzldl/Screenshot%202016-07-10%2015.48.16.png?dl=0
(defprotocol SampleProtocol
(some-method [this]))
(om/defui ^:once SampleClass
static om/IQuery
(query [_] [:query])
#!/bin/bash
set -e -u
# Created publish-local script that publish the repo to your ~/.m2/repository
# using your projects name and current version
# It assumes that you are:
# - in the same directory as the project.clj
# - the project name and version string are on the first line
project_name=$(head -n 1 project.clj | cut -d' ' -f2)
@wilkerlucio
wilkerlucio / debounce.cljs
Created June 20, 2016 13:12 — forked from scttnlsn/debounce.cljs
core.async debounce
(defn debounce [in ms]
(let [out (chan)]
(go-loop [last-val nil]
(let [val (if (nil? last-val) (<! in) last-val)
timer (timeout ms)
[new-val ch] (alts! [in timer])]
(condp = ch
timer (do (>! out val) (recur nil))
in (if new-val (recur new-val)))))
out))