Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Nick Bauman nickbauman

🎯
Focusing
View GitHub Profile
@nickbauman
nickbauman / anagram.clj
Created Nov 15, 2021
Clojure anagram detector
View anagram.clj
(defn split-string [word]
(into #{} (clojure.string/split word #"")))
(defn anagram-of? [word candidate]
(boolean (when (= (count word) (count candidate))
(let [word-list (split-string word)
cand-list (split-string candidate)]
(= #{} (clojure.set/difference cand-list word-list))))))
View haversine.clj
(ns haversine
(:require [math.numeric-tower :refer [expt sqrt]]))
(def RADIUS_OF_EARTH 6371.0088)
(defn radians [degrees]
(/ (* degrees Math/PI) 180))
(defn haversine
[lat1 lon1 lat2 lon2]
@nickbauman
nickbauman / ios_imperatives_for_approval.md
Last active Nov 1, 2019
Condensed iOS Human Interface Guidelines, formulated as imperatives.
View ios_imperatives_for_approval.md

Condensed iOS Human Interface Guidelines

Imperatives for AppStore approval

For iPhone app developers. Emphasis on getting the fastest app store approval. Everything stated as suggestion made into an imperative. When "violating" these imperatives, you can check for yourself what the caveats are. Generally speaking, deviating will more likely cause your app to be hung up in approval.

You can read this entire document in about 20 minutes. This is faster than reading and understanding the entire Human Interface Guidelines.

Overview

@nickbauman
nickbauman / rpi_backup_recover.sh
Created Jan 14, 2014
Mac backup your raspberry pi. Requires SSH client, dd, gzip installed
View rpi_backup_recover.sh
#Mac Backup your Raspberry Pi
#Backup remotely (requires public key exchange for pi account):
ssh pi@raspberry sudo dd if=/dev/mmcblk0 | gzip -c > raspberry.img.gz
#Recover (requires locally mounted disk device rdisk1):
gzip -dc /path/to/raspberry.img.gz | sudo dd of=/dev/rdisk1 bs=1m
@nickbauman
nickbauman / personal_list_gh_repos.py
Last active Apr 21, 2019
Lists all the repos, pub and priv, of a github user or organization. Prompts for password and/or 2FA token
View personal_list_gh_repos.py
from github3 import login
# Python 3
prompt = input
if __name__ == '__main__':
if len(sys.argv) > 1:
passwd = prompt('Enter password: ')
View keybase.md

Keybase proof

I hereby claim:

  • I am nickbauman on github.
  • I am nickbauman (https://keybase.io/nickbauman) on keybase.
  • I have a public key ASBzshC47DubC4RLKb4OF8rS3fcKT3EG4caYwlipybiLkAo

To claim this, I am signing this object:

@nickbauman
nickbauman / go_vs_clojure_habits.txt
Last active Jul 8, 2017
Go vs. Clojure: Habits of Thinking
View go_vs_clojure_habits.txt
The goal is to insert an integer into an ordered list-like thingy.
Here's Go.
// Given g
g := []int{1, 2, 3, 4}
// Insert 44 in the middle of it
append(g[:2], append([]int{44}, g[2:]...)...)
@nickbauman
nickbauman / example_gae_ds.clj
Last active Nov 19, 2016
Clojure GAE Clojure Datastore API
View example_gae_ds.clj
(defentity AnotherEntity [content saved-time int-value])
(deftest test-query-language
(testing "query entity with predicates"
(let [entity (save! (create-AnotherEntity "Some content woo" (t/date-time 1980 3 5) 6))
entity2 (save! (create-AnotherEntity "Other content" (t/date-time 1984 10 12) 17))]
; query all
(is (= (list entity entity2) (query-AnotherEntity [])))
; equality
(is (= (list entity) (query-AnotherEntity [:content = "Some content woo"])))
@nickbauman
nickbauman / git_tips.txt
Last active May 15, 2016
A star-gazing colleague shared this with me. I find it useful for taming some of the many git rough edges.
View git_tips.txt
# For the ~/.gitconfig file:
[alias]
st = status
co = checkout
ci = commit
cp = cherry-pick
br = branch
undo = reset HEAD~1 --mixed
back = stash pop
View keybase.md

Keybase proof

I hereby claim:

  • I am nickbauman on github.
  • I am nickbbuzzfeed (https://keybase.io/nickbbuzzfeed) on keybase.
  • I have a public key whose fingerprint is 98DD 9A39 33A9 9607 756A 1816 07E7 7FC3 9629 7825

To claim this, I am signing this object: