Skip to content

Instantly share code, notes, and snippets.

View ddeaguiar's full-sized avatar

Daniel De Aguiar ddeaguiar

  • Nubank
  • Miami, Fl
View GitHub Profile
(defun set-exec-path-from-shell-PATH ()
"Set up Emacs' `exec-path' and PATH environment variable to match that used by the user's shell.
This is particularly useful under Mac OSX, where GUI apps are not started from a shell."
(interactive)
(let ((path-from-shell (replace-regexp-in-string "[ \t\n]*$" "" (shell-command-to-string "$SHELL --login -i -c 'echo $PATH'"))))
(setenv "PATH" path-from-shell)
(setq exec-path (split-string path-from-shell path-separator))))
(set-exec-path-from-shell-PATH)
(ns noti.notify
(:require [noti.notification :as n]
[io.pedestal.service.log :as log]))
(defprotocol Notifiable
(notify! [_ x]))
(defmacro notifiable [body]
`(reify Notifiable
(notify! [_ notification]
(defn listen [el type]
(let [out (chan)]
(events/listen el type
(fn [e] (put! out e)))
out))
...
...
(defn init []
#lang racket
;; Named let (Section '4.6.4 Named let' of
;; http://docs.racket-lang.org/guide/let.html)
(define (duplicate-shorthand pos lst)
(let dup ([i 0]
[lst lst])
(cond
[(= i pos) (cons (car lst) lst)]
@ddeaguiar
ddeaguiar / sub
Last active January 2, 2016 02:59
Racket submodule example
#lang racket
(module foo racket
(module bar typed/racket ;;submodules can leverage different languages
(provide baz three)
(define: three : Number 3)
(define (baz) '(foo bar baz))
(define (bit) '(this is private))))
(defn fetch-col [] (range 100))
(defn less-than-30? [x]
(> 30 x))
(defn filter-col [a]
(filter #(every? true? ((juxt less-than-30? odd?) %)) a))
(defn report-results [col]
(println col)
@ddeaguiar
ddeaguiar / gist:10010756
Created April 6, 2014 19:55
Racket examples - various implementations of list-length
#lang racket
(require racket/trace)
;; Recursive implementation of list length
(define (list-length l)
(if (empty? l)
0
#
# A simple theme that displays relevant, contextual information.
#
# Authors:
# Sorin Ionescu <[email protected]>
#
# Screenshots:
# http://i.imgur.com/nBEEZ.png
#
[Unit]
Description=subgun
[Service]
ExecStartPre=-/usr/bin/docker kill subgun-%i
ExecStartPre=-/usr/bin/docker rm subgun-%i
ExecStart=/usr/bin/docker run -rm -name subgun-%i -e SUBGUN_LISTEN=127.0.0.1:8080 -e [email protected] -e SUBGUN_API_KEY=key-779ru4cibbnhfa1qp7a3apyvwkls7ny7 -p 8080:8080 coreos/subgun
ExecStop=/usr/bin/docker kill subgun-%i
[X-Fleet]
@ddeaguiar
ddeaguiar / gist:d8a6485d5dd81f5bf527
Last active August 29, 2015 14:14
bidi routing sample
(ns routing.core
(:require [bidi.bidi :as b]
[bidi.ring :as r]
[ring.mock.request :refer [request] :rename {request mock-request}]))
(defn index-handler
[req]
{:status 200 :body "Index"})
(def handler-map