Skip to content

Instantly share code, notes, and snippets.

@daemianmack
daemianmack / flow-charts-in-org-mode
Last active May 11, 2020 18:18
Generating a flow chart in org-mode
;; Using org-mode to describe state transitions with embedded elisp to
;; emit those state transitions as a graphical flow-chart via dot
;;
;; Modified with minor improvements from https://orgmode.org/worg/org-tutorials/org-dot-diagrams.html
;;
;; Place cursor in elisp code-block, eval with `C-c C-c`.
#+NAME: nodes
| *node* | *label* | *shape* | *fillcolor* | fg |
|-----------------------------+------------------------------------+---------+----------------+-------|
@daemianmack
daemianmack / keybase.md
Created September 4, 2018 18:02
keybase.md

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@daemianmack
daemianmack / hack-system.clj
Created June 19, 2017 19:36
Wrap the dev-system
;; I use this to wrap the `dev-system` in a way that...
;; - Alerts me when the system launch completes so I can do something
;; else while waiting, without getting sidetracked
;; - Alerts me when the system launch hangs
;; - Runs Eastwood
;; - Squelches logging from namespaces whose logging statements
;; frequently mask the logging I'm trying to see
;; I put this in ./dev and then
;; `printf ":/Users/daemian/src/ww/elephant/dev" >> build/cached-classpath`
@daemianmack
daemianmack / gist:b3468a8eb3d6df37d5b7
Created November 8, 2014 18:34
SML mode tweaks for REPL workflow
(require 'sml-mode)
(global-set-key (kbd "C-c S") 'sml-run)
;; Requires sml binary on PATH...
;; export PATH=$PATH:/usr/local/smlnj/bin
;; README
;; To load a file and run sml repl -> Press C-c C-v inside a sml file.
;; To run the current files tests -> Press C-c C-r inside a sml file. It assumes the tests are inside the same directory.
;; For example, If your code file is hw1.sml your test file should be named as hw1test.sml in the same directory
(defrecord Server [service-map]
component/Lifecycle
(start [component]
(info :msg "Starting server.")
(let [server (bootstrap/create-server (:service-map service-map))]
(bootstrap/start server)
(assoc component :server server)))
(stop [component]
(info :msg "Stopping server.")
(update-in component [:server] bootstrap/stop)))
@daemianmack
daemianmack / gdrive_filelister.rb
Created February 10, 2014 16:58
Authenticate via OAuth to the Google Drive API and list all files in the account
# Given a client_secrets.json file, authenticate via OAuth to the
# Google Drive API and list all files in the account.
# Setup:
## gem install google-api-client
## Under Google Developers Console, enable the Drive API and Drive SDK.
### Under Credentials > OAuth, create a new client ID.
#### This provides the client_secrets.json.
#### The Redirect URI must exactly match what the app actually sends.
@daemianmack
daemianmack / gist:3692024
Created September 10, 2012 16:41
Clojure Problem of the Day #9
(ns clj.core)
(def nums
(range 0 10))
(defn fair []
(rand-nth nums))
@daemianmack
daemianmack / gist:3385630
Created August 18, 2012 09:30
org chart scrape-builder from FM
require 'rubygems'
require 'set'
require 'hpricot'
require 'mechanize'
USER_ACCOUNT = "[email protected]"
PASSWORD = ARGV[0]
MAX_LINKS = 200
SLEEP_INTERVAL = 0.5
class Regular(object):
def __init__(self):
self.num = self.caller(5)
def not_inner(self, x):
return x * x
def caller(self, num):
return self.not_inner(num)
@daemianmack
daemianmack / rails_engines.md
Created July 20, 2012 16:44 — forked from westonplatter/controller_to_be_included.rb
using ActiveSupport::Concerns to extend Rails

Gist to describe the process of adding a namespaced isolated Rails Engine
to a typical Rails application and adding methods to one of the Rails Engine's
controller and model.

Index

  1. Rails applicaiton all by itself.
  2. Rails application with the Rails Engine (FooBar) mounted.
  3. Rails applicaiton partially extending a controller/model from the Rails Engine.