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
| /**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
| * Anchor Smooth Scroll - Smooth scroll to the given anchor on click | |
| * adapted from this stackoverflow answer: http://stackoverflow.com/a/21918502/257494 | |
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ | |
| angular.module('yourapp').directive('anchorSmoothScroll', function($location) { | |
| 'use strict'; | |
| return { | |
| restrict: 'A', | |
| replace: false, |
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
| - What do Etcd, Consul, and Zookeeper do? | |
| - Service Registration: | |
| - Host, port number, and sometimes authentication credentials, protocols, versions | |
| numbers, and/or environment details. | |
| - Service Discovery: | |
| - Ability for client application to query the central registry to learn of service location. | |
| - Consistent and durable general-purpose K/V store across distributed system. | |
| - Some solutions support this better than others. | |
| - Based on Paxos or some derivative (i.e. Raft) algorithm to quickly converge to a consistent state. | |
| - Centralized locking can be based on this K/V store. |
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
| (defn keyword->pg-enum | |
| "Convert a keyword value into an enum-compatible object." | |
| [enum-type kw] | |
| (doto (org.postgresql.util.PGobject.) | |
| (.setType enum-type) | |
| (.setValue (name kw)))) | |
| (def ->status | |
| "Convert a keyword status into a something_status enum object" | |
| (partial keyword->pg-enum "something_status")) |
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
| ko.bindingHandlers.dropzone = { | |
| init: function(element, valueAccessor) | |
| { | |
| var value = ko.unwrap(valueAccessor()); | |
| var options = { | |
| maxFileSize: 15, | |
| createImageThumbnails: false, | |
| }; |
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
| (set-env! :dependencies '[[leiningen-core "2.5.0"]]) | |
| (use 'leiningen.core.project) | |
| (eval (read-string (slurp "project.clj"))) | |
| (set-env! | |
| :source-paths (:source-paths project) | |
| :resource-paths (:resource-paths project) | |
| :dependencies (:dependencies project)) | |
We're working on a project that uses the Datomic Pull API to pull specific attributes out of Datomic entities. Here's an example of query that uses the Pull API:
(d/q '[:find [(pull ?e [:sales/deal_number :sales/deal_close_date :sales/state]) ...]
:in $ ?date
:where [?e :sales/deal_close_date ?d _ _] [(> ?d ?date)]]
db
(days-ago-at-midnight 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
| defmodule MyApp.Mixfile do | |
| use Mix.Project | |
| def project do | |
| [app: :my_app, | |
| version: get_version, | |
| elixir: "~> 1.0", | |
| elixirc_paths: elixirc_paths(Mix.env), | |
| compilers: Mix.compilers, | |
| build_embedded: Mix.env == :prod, |
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
| package main | |
| import ( | |
| "bufio" | |
| "io/ioutil" | |
| "os/signal" | |
| //"syscall" | |
| "fmt" | |
| "log" | |
| "os" |
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
| package main | |
| import ( | |
| "fmt" | |
| "reflect" | |
| ) | |
| // Name of the struct tag used in examples | |
| const tagName = "validate" |