Skip to content

Instantly share code, notes, and snippets.

View yanatan16's full-sized avatar

Jon Eisen yanatan16

View GitHub Profile

help

this

out

@yanatan16
yanatan16 / curl_data_200.txt
Created March 6, 2016 21:38
quasar-analytics/quasar#7
$ curl http://localhost:8080/data/fs/local/quasar/wide2{ "user_id": 8927524.0, "profile_name": "Mary Jane", "age": 29.0, "title": "Dr", "comment_id": "F2372BAC", "comment_text": "I concur.", "comment_reply_to_profile": 9817361.0, "comment_reply_to_comment": "F8ACD164F", "comment_time": "2015-02-03", "a1user_id": 8927524.0, "a1profile_name": "Mary Jane", "a1age": 29.0, "a1title": "Dr", "a1comment_id": "F2372BAC", "a1comment_text": "I concur.", "a1comment_reply_to_profile": 9817361.0, "a1comment_reply_to_comment": "F8ACD164F", "a1comment_time": "2015-02-03", "a2user_id": 8927524.0, "a2profile_name": "Mary Jane", "a2age": 29.0, "a2title": "Dr", "a2comment_id": "F2372BAC", "a2comment_text": "I concur.", "a2comment_reply_to_profile": 9817361.0, "a2comment_reply_to_comment": "F8ACD164F", "a2comment_time": "2015-02-03", "a3user_id": 8927524.0, "a3profile_name": "Mary Jane", "a3age": 29.0, "a3title": "Dr", "a3comment_id": "F2372BAC", "a3comment_text": "I concur.", "a3comment_reply_to_profile": 9817361.0, "a3comment_r
@yanatan16
yanatan16 / channel.cljc
Last active January 6, 2016 18:46
funcool/cats src/cats/labs/channel.cljc a4005de6eed28ba513d65ba028b3df18b68ec7f5
;; Copyright (c) 2014-2015 Andrey Antukh <[email protected]>
;; Copyright (c) 2014-2015 Alejandro Gómez <[email protected]>
;; All rights reserved.
;;
;; Redistribution and use in source and binary forms, with or without
;; modification, are permitted provided that the following conditions
;; are met:
;;
;; 1. Redistributions of source code must retain the above copyright
;; notice, this list of conditions and the following disclaimer.
@yanatan16
yanatan16 / integer-float-bug.md
Last active November 4, 2015 18:29
quasar integer to float conversion bug

When querying inside the loc float array, pop becomes a float instead of an integer.

$ # SELECT pop, loc[0], loc[1] FROM zips LIMIT 10
$ curl 'http://localhost:8080/query/fs/local/quasar?q=SELECT%20pop%2C%20loc%5B0%5D%2C%20loc%5B1%5D%20FROM%20zips%20LIMIT%2010' -H'Accept: text/csv'

pop,1,2
15338.0,-72.622739,42.070206
36963.0,-72.51565,42.377017
@yanatan16
yanatan16 / tap.clj
Last active August 29, 2015 14:27
tap doesnt work for the second channel if already closed
(require '[clojure.core.async :refer (<!! >!! close! chan mult tap alt!! timeout)])
(defn assert-closed! [c m] (assert (= nil (alt!! c ([v] v) (timeout 50) ([_] :timeout))) m))
(let [[c1 c2 c3] (repeatedly 3 chan)
_ (close! c1)
m (mult c1)]
(tap m c2)
(<!! (timeout 50))
(tap m c3)
@yanatan16
yanatan16 / README.md
Last active August 29, 2015 14:26
clojurescript compilation under :optimizations :simple

So this is the compilation I'm getting inside my larger project under :optimizations :simple (cljs 1.7.28)

The real problem is this:

Line 7 of the output code sets $_STAR_format_str_STAR_27199$$ = $_STAR_format_str_STAR_27199$$.indexOf("~") for line 12 in the input code of (let [tilde (.indexOf s \~)] ...).

Now, $_STAR_format_str_STAR_27199$$ seems to be standing in for s in the input code. Why is closure renaming tilde into overwriting s?

Later, at the end of line 9 (output) or line 15 (input), (subs s 1) / cljs.core.subs.call(null, $_STAR_format_str_STAR_27199$$, 1) causes an error because we have tilde, s and *format-str* sharing a variable name.

@yanatan16
yanatan16 / roshi.md
Last active April 19, 2017 21:03
explain roshi

Roshi is a set CRDT store modeled as a stateless web server in front of N (clusters) x M (shards) redis servers. It has 3 operations: Insert, Select, and Delete

Each element is a {"key", "member", "score"}

  • A key is the set name essentially. You select based on key. keys can be merged on select.
  • A member is the unique name of a member of the set
  • A score is a numeric value that has multiple uses.
    • If two elements with the same key and member are inserted, a select will only return the one with the highest score
@yanatan16
yanatan16 / de_async.clj
Last active August 29, 2015 14:22
de-async: Channel that returns channels
(require '[clojure.core.async :refer (go go-loop <! >! >!! chan close! alts!)])
(defn de-async
"From is a channel of channels.
Returns a new channel that has the values of the channels.
Closes when all channels are closed."
[from]
(let [to (chan)]
(go-loop [cs [from]]
(if-not (empty? cs)
@yanatan16
yanatan16 / transducers.js
Created September 23, 2014 05:14
TRANSducers!
// function reducing(acc, next) {
// return next_acc
// }
// function transducing(reducing) {
// return more_reducing
// }
// Example reducer (without transducers)
@yanatan16
yanatan16 / goooal.js
Created August 12, 2014 22:17
functional.goooooal.js
// this a lazy evaluation of the delayed value
// If the delayed value is delayed (i.e. a function), then return a function that will resolve eventually
// If not, then resolve immediately and prefix
function resolve(prefix, delayed_value) {
if (typeof delayed_value === 'function')
return function (a) { return resolve(prefix, delayed_value(a)) }
else
return prefix + delayed_value
}