Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git archive --format=tar origin/master | gzip -9c | ssh [email protected] "cd /var/www; tar xvzf -" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
description "Run clojure app" | |
start on runlevel startup | |
stop on runlevel shutdown | |
respawn | |
env PORT=5000 | |
exec java -cp /var/www/app.jar clojure.main -m app.handler |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get update | |
sudo apt-get install nginx | |
sudo update-rc.d nginx defaults | |
wget -O - https://debian.neo4j.org/neotechnology.gpg.key | sudo apt-key add - | |
echo 'deb https://debian.neo4j.org/repo stable/' | sudo tee /etc/apt/sources.list.d/neo4j.list | |
sudo apt-get update | |
sudo apt-get install neo4j |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The Heroku/Clojure/GrapheneDB Setup | |
# To enable custom build task. default is `lein uberjar` this changes it to `lein ring uberjar` | |
heroku config:add LEIN_BUILD_TASK="ring uberjar" | |
# To run a ring server uberjar, in the Procfile | |
web: java $JVM_OPTS -jar target/my-app.jar | |
# Because the GRAPHENEDB_URL does not end with `/db/data` | |
(def db-url |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When there is a profiles.clj file in the project directory, | |
and it has entries like: {:profiles {:dev {:special-password "secret"}}} | |
M-x set-variable cider-lein-parameters "with-profile +my-special-snowflake repl :headless" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user> (defn page-search | |
[search-term & {:keys [page page-size] :or {page 0 page-size 100}}] | |
(case page | |
0 {:items ["page zero"]} | |
1 {:items ["page one"]} | |
2 {:items ["page two"]} | |
nil)) | |
#'user/page-search | |
user> (defn lazy-page-search | |
[search-term & {:keys [page page-size] :or {page 0 page-size 100}}] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scp -v -r resources/public/* dirnet:/var/www/static/ | |
lein ring uberjar | |
rsync --verbose --progress -t target/*.jar dirnet:/var/www | |
ssh host "sudo service my-app restart" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <sys/mman.h> | |
#include <unistd.h> | |
typedef int (*factorial_func)(int); | |
#define X86_64_CALLING_CONVENTION 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (float->hex fl) | |
(string-append "0x" | |
(with-output-to-string | |
(lambda () | |
(write-ieee-float32 fl | |
(make-output-port | |
(lambda (m . args) | |
(case m | |
((write-char) | |
(format #t "~X" (char->integer (car args)))))) (make-string 0)) |