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 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
(require '[clojure.core.match :refer [match]] | |
'[clojure.string :as str] | |
'[hiccup2.core :refer [html]] | |
'[org.httpkit.server :as server]) | |
(defn router [req] | |
(let [paths (vec (rest (str/split (:uri req) #"/")))] | |
(match [(:request-method req) paths] | |
[:get ["users" id]] {:body (str (html [:div id]))} | |
:else {:body (str (html [:html "Welcome!"]))}))) |
Magic words:
psql -U postgres
Some interesting flags (to see all, use -h
or --help
depending on your psql version):
-E
: will describe the underlaying queries of the\
commands (cool for learning!)-l
: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
This file contains 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
# Source: http://timcardenas.com/automatically-reload-gems-in-rails-327-on-eve | |
# Inside config/environments/development.rb | |
# Do the following after every request to the server in development mode | |
ActionDispatch::Callbacks.to_cleanup do | |
# If the gem's top level module is currently loaded, unload it | |
if Object.const_defined?(:MyCoolGem) |