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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> | |
<title>Testing Pie Chart</title> | |
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?2.1.3"></script> | |
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.geom.js?2.1.3"></script> | |
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.layout.js?2.1.3"></script> | |
<style type="text/css"> |
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
;; | |
;; NS CHEATSHEET | |
;; | |
;; * :require makes functions available with a namespace prefix | |
;; and optionally can refer functions to the current ns. | |
;; | |
;; * :import refers Java classes to the current namespace. | |
;; | |
;; * :refer-clojure affects availability of built-in (clojure.core) | |
;; functions. |
Create an account at https://openweathermap.org and get an API key.
Note that it can take up to a couple of hours for the key to become active.
Add an environment variable OPEN_WEATHER_API_KEY
with the value of the key.
run the script:
./weather.clj Toronto,CA
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
package main | |
import ( | |
"net/http" | |
"database/sql" | |
"fmt" | |
"log" | |
"os" | |
) |
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
# Adapted from https://tinyapps.org/blog/nix/201701240700_convert_asciidoc_to_markdown.html | |
# Using asciidoctor 1.5.6.1 and pandoc 2.0.0.1 | |
# Install pandoc and asciidoctor | |
$ sudo apt install asciidoctor | |
$ sudo wget https://github.com/jgm/pandoc/releases/download/2.0.0.1/pandoc-2.0.0.1-1-amd64.deb | |
$ sudo dpkg -i pandoc-2.0.0.1-1-amd64.deb | |
# Convert asciidoc to docbook using asciidoctor |
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
defmodule Box do | |
defmacro __using__(_env) do | |
quote do | |
import Box | |
end | |
end | |
@doc """ | |
Define module with struct and typespec, in single line |
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
(ns clojure.polling | |
(:require [clj-http.client :as client] | |
[clojure.core.async :as async :refer [>!! timeout <! go-loop]] | |
[cheshire.core :as json] | |
[clojure.tools.logging :as log])) | |
(defn client | |
([endpoint] | |
(client/get endpoint)) | |
([endpoint c e] |
NewerOlder