Skip to content

Instantly share code, notes, and snippets.

View slagyr's full-sized avatar

Micah Martin slagyr

  • Clean Coders, LLC
  • Scottsdale, AZ
View GitHub Profile
@slagyr
slagyr / pyfe.py
Created February 27, 2019 02:17
Game of Life in Python
from funcy import mapcat
class Pyfe:
def __init__(self):
self._living_cells = set()
@property
def living_cells(self):
return self._living_cells
@slagyr
slagyr / gist:42c06f51d9faafe2fc58
Last active January 9, 2019 23:44
asyn exceptions
(ns slagyr.async)
(den foo []
(js/setTimeout
(fn [] (throw (js/Error. "foo")))
100))
(try
(foo)
(catch js/Object e
@slagyr
slagyr / autumn.js
Last active January 9, 2019 23:44
Autumn code
/**
* Micah's Autumn setup
*/
alert('Running Autumn!');
/**
* Window management
*/
@slagyr
slagyr / gist:950574
Created May 1, 2011 15:22
Game of Life in 8 lines of Clojure
(defn neighbors-of [cell]
(set (for [dx [-1 0 1] dy [-1 0 1] :when (not (= [dx dy] [0 0]))]
[(+ dx (first cell)) (+ dy (second cell))])))
(defn alive? [[cell freqs] world]
(or (and (= 2 freqs) (contains? world cell)) (= 3 freqs)))
(defn tick [world]
(let [frequencies (frequencies (reduce #(concat %1 (neighbors-of %2)) [] world))]
(set (keys (filter #(alive? % world) frequencies)))))
(def sm {:sleeping {:_on-entry [:tracking-0]
:_default [:sleeping]
:start [:taxiing [:start-leg]]
:stop [:sleeping [:cancel-leg]]
:entry [:treading]
:scud [:scudding [:start-leg]]
:cruise [:cruising [:start-leg]]}
:treading {:_on-entry [:tracking-1]
:_default [:treading]
:start [:taxiing [:start-leg]]
server {
  listen 80;
  server_name <%= @server_name %>;
  return 301 https://<%= @server_name %>$request_uri;
}
(defn not-set
"Returns true if attr is not set for e"
[db e attr]
(let [result (api/q '[:find ?v
:in $ ?e ?a
:where [?e ?a ?v]]
db e attr)]
(-> result first empty?)))
(defn pets-without-tails [owner-id]
@slagyr
slagyr / gist:5961714
Created July 9, 2013 22:04
Frustrations with GAE
GAE made it really easy to get a scalable site up and running. I first used it while building cleancoders.com. But there were several things that irked me.
- The SDK is huge. And it was a bit challenging to integrate with the maven workflow.
- The 30 second hard limit was frustrating problem. We build measures into Gaeshi to handle this, but every once in a while, GAE would boot our app on exceptionally slow servers that couldn't serve our app on time.
- The use of Google login for administration was good and bad. At the time there was a 10 app limit, and collaborating with clients on the GAE admin site was awkward.
- The tight coupling with GAE's API and the Datastore made me uncomfortable.
- The straw that finally broke the camel's back was the blacklisted classes. We build an client app on GAE that worked fine locally, but when we pushed to GAE, it just wouldn't work because, to our surprise, java.awt is blacklisted.
Since starting cleancoders.com, I became much more familiar with Amazon's AWS. U
Ledger Part Nine
statement() prints in order
chronological
payment number
Add dates to all deposits and payments, autogenerate payment numbers
|script|empty ledger|
(ns doppler.auth.auth-controller
(:require [cheshire.core :refer [parse-string]]
[clj-oauth2.client :as oauth2]
[compojure.core :refer [defroutes GET context]]
[joodo.env :refer [env]]
[joodo.middleware.request :refer [*request*]]
[ring.util.response :refer [redirect]]))
(def google-com-oauth2 (merge (env :google-oauth )
{:authorization-uri "https://accounts.google.com/o/oauth2/auth"