Skip to content

Instantly share code, notes, and snippets.

View owenrh's full-sized avatar

Owen Rees-Hayward owenrh

View GitHub Profile
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:
@owenrh
owenrh / .log
Created September 22, 2021 15:23
Spark log schema by event type
---
Event type -> SparkListenerApplicationEnd
root
|-- Event: string (nullable = true)
|-- Timestamp: long (nullable = true)
---
Event type -> SparkListenerApplicationStart
@owenrh
owenrh / app.js
Created July 9, 2020 13:25
Apache & node.js experiments
const express = require('express')
const app = express()
const port = 3000
// sleep time expects milliseconds
function sleep (time) {
return new Promise((resolve) => setTimeout(resolve, time));
}
@owenrh
owenrh / noddy-scala.sc
Last active August 29, 2015 14:27
Noddy Scala for a blog post.
(1 to 10).map(_ + 2).reduce(_ + _)
// more 'relaxed' version
1 to 10 map(_ + 2) reduce(_ + _)
@owenrh
owenrh / noddy-clojure.clj
Last active August 29, 2015 14:27
Just something for a blog post.
(reduce + (map (comp inc inc) (range 1 11)))
@owenrh
owenrh / debounced-by-window.cljs
Last active August 29, 2015 14:27
Clojurescript browser event handler debouncing (via core.async) - window-based approach.
;; 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])]
@owenrh
owenrh / debounced.cljs
Last active May 11, 2017 12:55
Clojurescript browser event handler debouncing (via core.async)
;; 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])]