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
| %% Author: bokner | |
| %% Created: Apr 10, 2010 | |
| %% Description: HTTP digest authentication | |
| %% Note: the code follows the informal explanation given on Wikipedia. | |
| %% Note: the test/0 function doesn't intend to send a proper data to webdav service, | |
| %% it just shows how to pass the authorization. | |
| %% Disclaimer: Use on your own risk. The author disclaims any liability | |
| %% with regard to using this code. | |
| -module(digest_auth). |
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
| ;; Some example error messages resulting from common mistakes | |
| ;; using Datomic 0.8.4138 | |
| (ns errors | |
| (:use [datomic.api :as d :only (db q)])) | |
| (def uri "datomic:mem://database") | |
| (d/create-database uri) |
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
| { | |
| "AL": "Alabama", | |
| "AK": "Alaska", | |
| "AS": "American Samoa", | |
| "AZ": "Arizona", | |
| "AR": "Arkansas", | |
| "CA": "California", | |
| "CO": "Colorado", | |
| "CT": "Connecticut", | |
| "DE": "Delaware", |
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
| #!/bin/bash | |
| # Returns the IP address of a running KVM guest VM | |
| # Assumes a working KVM/libvirt environment | |
| # | |
| # Install: | |
| # Add this bash function to your ~/.bashrc and `source ~/.bashrc`. | |
| # Usage: | |
| # $ virt-addr vm-name | |
| # 192.0.2.16 | |
| # |
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
| -- xmobar config used by Vic Fryzel | |
| -- Author: Vic Fryzel | |
| -- http://github.com/vicfryzel/xmonad-config | |
| -- This is setup for dual 1920x1080 monitors, with the right monitor as primary | |
| Config { | |
| -- position = TopW C 80, | |
| position = Static { xpos = 0 , ypos = 0, width = 1806, height = 16 }, | |
| -- border = BottomB, | |
| borderColor = "grey", |
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
| (ns the-namespace.core | |
| (:require [clj-http.client :as client] | |
| [clojure.java.io :as io])) | |
| (defn- fetch-photo! | |
| "makes an HTTP request and fetches the binary object" | |
| [url] | |
| (let [req (client/get url {:as :byte-array :throw-exceptions false})] | |
| (if (= (:status req) 200) | |
| (:body req)))) |
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
| module("resty.consul", package.seeall) | |
| _VERSION = '0.1.0' | |
| function service_nodes(service) | |
| local http = require "resty.http" | |
| local json = require "cjson" | |
| local hc = http:new() | |
| local upstream = "" |
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
| { config, pkgs, ... }: | |
| let | |
| hostname = "luz3"; | |
| in { | |
| imports = | |
| [ # Include the results of the hardware scan. | |
| ./hardware-configuration.nix | |
| # I use VirtualBox to connect to Windows and Linux guests |
статья с описанием - http://habrahabr.ru/post/233243/
Поулчаем список городов http://weather.yandex.ru/static/cities.xml https://pogoda.yandex.ru/static/cities.xml
OlderNewer