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
// Thickness of the bottom of the tray itself. | |
base_z = 0.5; | |
// The width of the rim around the tray. | |
rim_width = 2; | |
// Height of the rim around the tray. This is the height over base_z. | |
rim_z = 2; | |
// Length of the drip tray (not including the notch). |
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
#!/bin/zsh | |
sudo port selfupdate | |
outdated_ports=$(port echo outdated) | |
if [[ -z $outdated_ports ]]; then | |
exit 0 | |
fi |
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
#!/bin/sh | |
# Running "eval $(goenv init -)" can take more than 100ms on a recent Macbook, most of that time spent | |
# on generating the commands, rather than evaluating them. But those commands are the same every time, | |
# so this generates those once, and caches it to disk. It doesn't check for freshness though, so it is | |
# prudent to delete ~/.goenv.cached.init.sh after updating goenv. | |
# To use: replace the call to "eval $(goenv init -)" with the following code | |
_cached_goenv_init() { |
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
(defmacro -> (form &rest forms) | |
(reduce | |
(lambda (acc next) | |
(if (listp next) | |
(list* (car next) acc (cdr next)) | |
(list next acc))) | |
forms | |
:initial-value form)) | |
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
;; AoC 2020 Day 4. Solve by generating a huge regex. | |
(require '[clojure.string :as s]) | |
(def sample-passports | |
"ecl:gry pid:860033327 eyr:2020 hcl:#fffffd | |
byr:1937 iyr:2017 cid:147 hgt:183cm | |
iyr:2013 ecl:amb cid:350 eyr:2023 pid:028048884 |
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
/** | |
* Four methods to test if an integer is a power of two. | |
* Compile with `-march=haswell`. | |
*/ | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <immintrin.h> | |
#include <time.h> |
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
#!/usr/bin/env python2 | |
""" | |
Soduko solver. Everybody writes one. | |
""" | |
sample = "003020600900305001001806400008102900700000008006708200002609500800203009005010300" | |
all_bits = int('1'*9,2) | |
def load_puzzle(s): |
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
;; https://twitter.com/sartanbegavhaum/status/1066051737650429952 | |
(defn non-trivial-factors [n] | |
(filter #(zero? (mod n %)) (range 2 n))) | |
(def prime? (comp empty? non-trivial-factors)) | |
(defn tomer-number? [n] | |
(when-let [facts (seq (non-trivial-factors n))] | |
(every? prime? facts))) |
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
(s/defn camel->lisp :- s/Str | |
[s :- s/Str] | |
(->> s | |
(re-seq #("?:^\p{javaLowerCase}|\p{javaUpperCase}\p{javaLowerCase}+")) | |
(map string/lower-case) | |
(string/join "-"))) | |
(s/defn keys-camel->list :- {s/Keyword s/Any} | |
[h :- {s/Keyword s/Any} & [recursive :- s/Bool]] | |
(into {} (map (fn [[k v]] [(-> k str (subs 1) camel->lisp) |
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
// Forwards all emails in the inbox from `from_email` to Expensify, and archive them. | |
// | |
// To use: | |
// Add this function to a Google Apps Scripts project, and add a trigger (in Resources -> Current Project Triggers) | |
// to call it on a given interval. | |
// Make sure to specify the senders you'd like to forward! | |
function toExpensifyBySender(from_email) { | |
var threads = GmailApp.search('from:' + from_email + ' in:inbox'); |
NewerOlder