Skip to content

Instantly share code, notes, and snippets.

View ekhall's full-sized avatar

EK Hall ekhall

  • Personal
  • New York, USA
View GitHub Profile
@ekhall
ekhall / pre
Created December 11, 2015 21:22
(defproject queuing "1.0.0-SNAPSHOT"
:description "Demo Clojure web app with queuing"
:license {:name "Eclipse Public License v1.0"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.7.0"]
[com.novemberain/langohr "3.3.0"]
[compojure "1.1.8"]
[ring/ring-jetty-adapter "1.2.2"]
[environ "0.5.0"]]
:min-lein-version "2.0.0"
@ekhall
ekhall / mqtt
Created December 11, 2015 20:41
(ns queuing.web
(:gen-class)
(:require
[langohr.core :as rmq]
[langohr.channel :as lch]
[langohr.queue :as lq]
[langohr.consumers :as lc]
[langohr.basic :as lb]
[compojure.core :refer [defroutes GET]]
[compojure.handler :refer [site]]
func dbPersistUser() {
let group: dispatch_group_t = dispatch_group_create()
let queue: dispatch_queue_t = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
dispatch_group_enter(group)
if self.sessionId == nil {
nik.restPath(Globals.kSessionURL,
method: "POST",
queryParams: [:],
@ekhall
ekhall / gist:09a4900dd074718c26bc
Created April 1, 2015 20:58
raco compile error
❯ raco exe window.rkt [16:57:48]
open-input-output-file: cannot open output file
path: /Users/hall/Desktop/window
system error: Permission denied; errno=13
context...:
/usr/local/Cellar/plt-racket/6.1.1/share/racket/collects/compiler/private/mach-o.rkt:349:0: get/set-dylib-path
/usr/local/Cellar/plt-racket/6.1.1/share/racket/collects/compiler/private/macfw.rkt:17:2: update-framework-path
/Users/hall/Library/Racket/6.1.1/pkgs/compiler-lib/compiler/commands/exe.rkt: [running body]
/usr/local/Cellar/plt-racket/6.1.1/share/racket/collects/raco/raco.rkt: [running body]
/usr/local/Cellar/plt-racket/6.1.1/share/racket/collects/raco/main.rkt: [running body]
#lang racket
(struct student (name id# dorm))
(define bob (student 'Bob 1234 'dorm1))
(list bob) ; -> '(#<student>)
'(bob) ; -> '(bob)
; I thought these two ways of creating lists were equivalent?
Country,Dwellings without basic facilities,Housing expenditure,Rooms per person,Household net adjusted disposable income,Household net financial wealth,Employment rate,Job security,Long-term unemployment rate,Personal earnings,Quality of support network,Educational attainment,Student skills,Years in education,Air pollution,Water quality,Consultation on rule-making,Voter turnout,Life expectancy,Self-reported health,Life satisfaction,Assault rate,Homicide rate,Employees working very long hours,Time devoted to leisure and personal care
Australia,1.1,20,2.3,31197,38482,72,4.4,1.06,46585,93,74,514,18.8,13,93,10.5,93,82,85,7.4,2.1,0.8,14.23,14.41
Austria,1,21,1.6,29256,48125,73,3.4,1.07,43837,95,82,498,16.9,27,95,7.1,75,81.1,69,7.5,3.4,0.5,8.61,14.46
Belgium,1.9,20,2.3,27811,78368,62,4.5,3.37,47276,91,71,507,18.8,21,84,4.5,89,80.5,74,7.1,6.6,1.2,4.41,15.71
Canada,0.2,22,2.5,30212,63261,72,6.6,0.9,44017,94,89,522,17,15,90,10.5,61,81,88,7.6,1.3,1.7,3.98,14.25
Chile,9.4,19,1.3,13762,18141,62,4.7,2.01,15438,85,72,439,1
(defn wrap-dump [handler]
(let [out-writer (java.io.FileWriter. "output.html")]
(fn [request]
(binding [*out* out-writer] (prn request))
(let [response (handler request)]
(binding [*out* out-writer] (prn response))
response))))
(def app
(-> (wrap-simulated-methods routes)
(ns patient.core
(:require [datomic.api :as d]))
(def conn nil)
(defn add-patient [patient-name]
@(d/transact conn [{:db/id (d/tempid :db.part/patient)
:patient/name patient-name}]))
(defn find-all-patients []
@ekhall
ekhall / gist:9630990
Last active August 29, 2015 13:57
Understanding &Enum.reduce/3
iex(11)> Enum.reduce([1, 2, 3, 4, 5], 0, fn(x, acc) -> IO.puts "x: #{x} acc: #{acc}";x + acc end)
x: 1 acc: 0
x: 2 acc: 1
x: 3 acc: 3
x: 4 acc: 6
x: 5 acc: 10
15
iex(12)>
iex> Stream.unfold({0,1}, fn {f1,f2} -> {f1, {f2, f1+f2}} end) |> Enum.take(15)
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377]