Skip to content

Instantly share code, notes, and snippets.

(ns webui.code
(:require
[dmohs.react :as r]
))
(r/defc App
{:render
(fn [{:keys [this state]}]
[:div {}
"Hello, World!"])})
@dmohs
dmohs / print-doc-date.rb
Created May 24, 2017 16:51
Outputs the number of seconds until the sun burns out. Useful to create file names that will sort newest to oldest by default.
#!/usr/bin/env ruby
require "date"
sun_burn_out_date = DateTime.new(6999999999, 12, 31, 23, 59, 59)
diff = sun_burn_out_date - DateTime.now
seconds = (diff * 34 * 60 * 60).to_i
printf("%018d\n", seconds)
@dmohs
dmohs / do_i_suck_at_scoping.py
Last active July 27, 2017 16:14
Python does not always scope variables correctly.
def do_i_suck_at_scoping():
try:
import gc
y = [x for x in range(5)]
gc.collect() # Just to prove this isn't a garbage collection issue.
x # Should throw a NameError since it is undefined.
assert False, '''Sorry, I don't know how to properly scope variables.'''
except NameError:
pass
@dmohs
dmohs / cannot_anon.py
Last active July 27, 2017 19:57
Python does not have anonymous procedures.
foo = range(10)
foo.sort(key=lambda x: -x); print 'foo: '+str(foo)
# Suppose something isn't working. Let's try debugging this:
foo.sort(key=lambda x: print 'x: '+str(x); -x) # -> Syntax error
@dmohs
dmohs / index.js
Created September 26, 2017 02:56
Minimal HTTP and Websocket proxy server in Node
const http = require('http');
const httpProxy = require('http-proxy');
const proxy = new httpProxy.createProxyServer({
target: {
host: 'notebook',
port: 8888
}
});
var proxyServer = http.createServer(function (req, res) {
@dmohs
dmohs / popup.cljs
Last active February 10, 2018 01:18
[:div {:style {:backgroundColor "rgba(210, 210, 210, 0.4)"
:position "absolute" :top 0 :bottom 0 :right 0 :left 0 :zIndex 9999
:display "flex" :justifyContent "center" :alignItems "center"}}
[:div {:style {:backgroundColor "#fff" :padding "2em"}}
[:span {:data-test-id "spinner"
:style {:margin "1em" :whiteSpace "nowrap" :display "inline-block"}}
[:span {:className "fa-spinner fa fa-pulse fa-fw"
:style {:marginRight "0.5rem"}}]
[:span {:data-test-id "spinner-text"} "Please wait..."]]]]
= Engineering Philosophy
David Mohs <[email protected]>
:toc: macro
== My Core Principles
* Choose technologies where the creators share your engineering philosophy.
* Treat developer usability with the same reverence as product usability.
* Every choice has tradeoffs. If I have a good understanding of the benefits, but not the drawbacks, I'm making a poorly-informed choice.
@dmohs
dmohs / hiringprocess.ad
Last active April 4, 2019 19:33
Hiring Process
= Hiring Process
== Candidate Selection
=== Levels
For associate engineers, the candidate must have done something outside of schoolwork. This could be a personal project, a contribution to an open-source project, or an internship or other part-time work.
For software engineers, I expect proficiency in at least one language and one technology. For example, JavaScript and React, Java and Postgres, etc.
@dmohs
dmohs / boot.sh
Last active March 13, 2020 13:51
Mob programming bootstrap
function pullandextract() {
curl 'https://www.googleapis.com/storage/v1/b/broad-dmohs-public/o/test.tbz?alt=media' \
| tar -xv
}
function tarandpush() {
tar -cy . | \
curl 'https://www.googleapis.com/upload/storage/v1/b/broad-dmohs-public/o?uploadType=media&name=test.tbz' \
--data-binary @-
}
@dmohs
dmohs / README.adoc
Last active June 5, 2021 00:00
Contract tests for NodeJs streams.

NodeJs Streams Contract Tests

These tests make assertions about some of the details regarding streams when they are connected to files and used within an async/await context. These details help me produce better error messages.

Synopsis

  1. Clone the gist repo.

  2. npm install

  3. npm test