- Create an app following the official Shadow-CLJS Quick Start instructions.
- Modify
shadow-cljs.edn
;; shadow-cljs configuration
{:source-paths
["src/dev"
"src/main"
"src/test"]
;; ADD - CIDER middleware for nREPL (required by fireplace.vim)
/* | |
* qjsc -fno-eval -m -o ohai ohai.js | |
*/ | |
"use strict"; | |
"use math"; | |
import * as std from "std" | |
import * as os from "os" | |
// dl'd from gh for local use |
// | |
// it all adds up *whomp whomp* | |
// | |
const add = function (a, b) { | |
return a + b | |
} | |
const add10 = x => add(10, x) | |
const add100 = add.bind(null, 100) |
export function sum(...a) { | |
function loop(arr, total = 0) { | |
if (arr.length === 0) return total; | |
else return loop(arr.slice(1), total + arr[0]); | |
} | |
return loop(a); | |
} |
(by @andrestaltz)
So you're curious in learning this new thing called (Functional) Reactive Programming (FRP).
Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:
Rx.Observable.prototype.flatMapLatest(selector, [thisArg])
Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.
#!/bin/bash | |
# | |
# Report time to first byte for the provided URL using a cache buster to ensure | |
# that we're measuring full cold-cache performance | |
while (($#)); do | |
echo $1 | |
curl -so /dev/null -H "Pragma: no-cache" -H "Cache-Control: no-cache" \ | |
-w "%{http_code}\tPre-Transfer: %{time_pretransfer}\tStart Transfer: %{time_starttransfer}\tTotal: %{time_total}\tSize: %{size_download}\n" \ | |
"$1?`date +%s`" |
warrior = { str: 17, int: 8, dex: 12, con: 16, luk: 10 } | |
strength, dexterity, luck = warrior.values_at(:str, :dex, :luk) | |
to_hit = strength ... |
# | |
# I like to gamble | |
# | |
Gambler = Struct.new(:nick, :chip_count) do | |
def to_s | |
"#{nick}: Ð #{chip_count}" | |
end | |
end |
# | |
# http://www.mutt.org/doc/manual.txt | |
# | |
# basic .muttrc for use with Gmail | |
# Change the following six lines to match your Gmail account details | |
set imap_user = "[email protected]" | |
set imap_pass = "" | |
set smtp_url = "smtp://[email protected]:587/" |