This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; this is not a windowed debounce, it is a paused debounce | |
;; (the timer is reset on each non-timer value) | |
(defn debounce [ms somefunc] | |
(let [in (chan) | |
out (chan)] | |
; debounce in channel - based on https://gist.github.com/scttnlsn/9744501 | |
(go-loop [last-val nil] | |
(let [val (if (nil? last-val) (<! in) last-val) | |
timer (timeout ms) | |
[new-val ch] (alts! [in timer])] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; window-based debounce | |
;; (passes the existing timer through on recur) | |
(defn debounce [ms somefunc] | |
(let [in (chan) | |
out (chan)] | |
; debounce in channel - based on https://gist.github.com/scttnlsn/9744501 | |
(go-loop [last-val nil | |
timer (timeout ms)] | |
(let [val (if (nil? last-val) (<! in) last-val) | |
[new-val ch] (alts! [in timer])] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(reduce + (map (comp inc inc) (range 1 11))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(1 to 10).map(_ + 2).reduce(_ + _) | |
// more 'relaxed' version | |
1 to 10 map(_ + 2) reduce(_ + _) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express') | |
const app = express() | |
const port = 3000 | |
// sleep time expects milliseconds | |
function sleep (time) { | |
return new Promise((resolve) => setTimeout(resolve, time)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
Event type -> SparkListenerApplicationEnd | |
root | |
|-- Event: string (nullable = true) | |
|-- Timestamp: long (nullable = true) | |
--- | |
Event type -> SparkListenerApplicationStart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import glob | |
for in_file in glob.glob('/home/owen/logs/some-spark-job-log*.log'): | |
out_file = f'{in_file}.p' | |
with open(in_file, mode='r') as f: | |
with open(out_file, mode='w') as out: | |
for line in f: | |
if len(line) > 2: |