Skip to content

Instantly share code, notes, and snippets.

(fn atom (v) {"v" v})
(fn deref (atm) (:atm "v"))
(fn reset! (atm newv)
(= (:atm "v") newv)
(deref atm))
(fn swap! (atm f)
(reset! atm (apply f [(:atm "v")])))
require 'lib/rns'
require 'lib/dbutil'
Db = Rns(DbUtil => [:with_statement, :fetch_all]) do
def get_list(conn, shortcode)
sql = <<EOS
SELECT todo, state
FROM todos t INNER JOIN lists l
ON t.list_id = l.id
WHERE l.id=?
#!/bin/bash
TARGET="alan@telavant.com:/www/todoshark.com/subdomains/dev/"
rsync -vv -a . $TARGET
inotifywait -r -m -e close_write --format '%w%f' . | while read F; do
echo "sending $F"
scp "$F" "${TARGET}/${F}"
done
@alandipert
alandipert / method.rb
Created September 1, 2014 14:55
unary ~ on Symbol for a Lisp-2 feel
class Symbol
def ~@
method(self)
end
end
def inc(n)
n + 1
end
@alandipert
alandipert / index.cgi
Created September 1, 2014 20:48
Mount a rack app into a CGI script
#!/usr/bin/ruby
require 'rubygems'
Gem.use_paths(nil, Gem.path << "/home/alan/.gem/gems")
require 'bundler'
require 'rack'
require 'app'
Rack::Handler::CGI.run App.new
fakegen.core> (doseq [x (repeatedly 100 company/bs)] (println x))
mesh best-of-breed bandwidth
monetize user-centric content
scale global partnerships
streamline 24/7 web services
matrix collaborative e-business
utilize enterprise bandwidth
benchmark out-of-the-box users
iterate cross-platform communities
matrix efficient relationships
@alandipert
alandipert / with_ns.clj
Created September 15, 2014 16:06
Namespaces inside other ones
(defmacro with-ns [sym & body]
`(binding [*ns* (create-ns '~sym)]
(refer-clojure)
~@(for [form body] `(eval '~form))))
user> (shuffle (range 10))
[0 7 3 1 9 8 6 2 5 4]
user> (doseq [n *1] (future (Thread/sleep (* 1000 n)) (println n)))
(set-env! :dependencies '[[alandipert/hyperturbo "0.0.1-SNAPSHOT"]])
(require '[alandipert.hyperturbo :refer [TURBO GOTO]])
(TURBO
10 (println "Docker boot hahahaha!")
20 (GOTO 10))
;;; javelin input cell
(def n (cell 0))
;;; javelin formula cell
(def n*5 (cell= (* n 5)))
;;; reagent atom "slaved" to n*5
(def count (r/atom nil))
(cell= (swap! count assoc :count n*5))