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
(page "index.html" | |
(:require-macros [cljs.core.match.macros :refer [match]]) | |
(:require [cljs.core.match] | |
[tailrecursion.hoplon.reload :refer [reload-all]]) | |
(:refer-clojure :exclude [hash])) | |
(reload-all 1000) | |
(defn route [parts] | |
(match [parts] |
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
class Symbol | |
def ~@ | |
method(self) | |
end | |
end | |
def inc(n) | |
n + 1 | |
end |
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
{-# LANGUAGE FlexibleInstances #-} | |
module Main where | |
import Control.Applicative ((<$>)) | |
import Control.Monad.State.Lazy as S | |
class Monad m => World m where | |
writeLine :: String -> m () | |
instance World IO where |
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
# If you have OpenSSL installed, we recommend updating | |
# the following line to use "https" | |
source 'http://rubygems.org' | |
gem "middleman", "~>3.2.2" | |
gem 'redcarpet' | |
# Live-reloading plugin | |
gem "middleman-livereload", "~> 3.1.0" |
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
%form.form-inline#mc-embedded-subscribe-form{ action: "[sign_up_url]", method: "post", name: "mc-embedded-subscribe-form", novalidate: "", target: "_blank"} | |
%input#mce-EMAIL.required.email{ name: "EMAIL", type: "email", value: "", placeholder: "email"}/ | |
%div{ style: "position: absolute; left: -5000px;" } | |
%input{ type: "text", name: "[hex_code]", value:"" } | |
%input#mc-embedded-subscribe{name: "subscribe", type: "submit", value: "Subscribe" }/ |
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
From 8ab91751069e391a95151c6716a546b1732ade92 Mon Sep 17 00:00:00 2001 | |
From: JP <twitter:canoeberry> | |
Date: Sun, 19 Jan 2014 11:58:54 +0000 | |
Subject: [PATCH] partial memleak fix | |
This patch was created by JP (twitter: @canoeberry) based on a memleak fix by Dirk (emacs committer) below: | |
https://github.com/mirrors/emacs/commit/57ae6509a3b6a274f89b9caea0284c6156470625 | |
This memory leak is fixed in the trunk as of now and will be in the next official release: 24.4. |
For most of the tools on here, if you follow the GitHub repos back to the user that owns the repo, they usually have other cool Clojure tools they build. Just a general observation about the Clojure community.
Learnings
- Clojure home - There's a ton of good stuff here, like the rationale behind the design and explanations of the best features of Clojure.
- Clojure.github.io - The core Clojure documentation. Useful for looking up functions and such.
- Clojuredoc - Community written Clojure documentation and articles
- Clojure Koans - Learn Clojure with Koans
- When you get stuck, use these YouTube videos to help you.
- 4Clojure - Solve simple problems to stretch your Clojure skills
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
(defn ignore-trailing-slash | |
"Modifies the request uri before calling the handler. | |
Removes a single trailing slash from the end of the uri if present. | |
Useful for handling optional trailing slashes until Compojure's route matching syntax supports regex. | |
Adapted from http://stackoverflow.com/questions/8380468/compojure-regex-for-matching-a-trailing-slash" | |
[handler] | |
(fn [request] | |
(let [uri (:uri request)] | |
(handler (assoc request :uri (if (and (not (= "/" uri)) |
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
#!/bin/bash | |
# Five step search and replace with find, sed, and bash (tested on OS X, should work with Linux) | |
# check usage and parse command line arguments | |
OPTIND=1 | |
while getopts "n:m:" opt; do | |
case "$opt" in | |
n) | |
human=$OPTARG |