This template is my ideal format for issues submitted to a github repository.
import java.security.InvalidKeyException; | |
import java.security.NoSuchAlgorithmException; | |
import java.security.SignatureException; | |
import java.util.Formatter; | |
import javax.crypto.Mac; | |
import javax.crypto.spec.SecretKeySpec; | |
/** |
(ns oauth.digest | |
(:import (javax.crypto Mac) | |
(javax.crypto.spec SecretKeySpec))) | |
(defn hmac | |
"Calculate HMAC signature for given data." | |
[^String key ^String data] | |
(let [hmac-sha1 "HmacSHA1" | |
signing-key (SecretKeySpec. (.getBytes key) hmac-sha1) | |
mac (doto (Mac/getInstance hmac-sha1) (.init signing-key))] |
(defn delete-recursively [fname] | |
(let [func (fn [func f] | |
(when (.isDirectory f) | |
(doseq [f2 (.listFiles f)] | |
(func func f2))) | |
(clojure.java.io/delete-file f))] | |
(func func (clojure.java.io/file fname)))) |
npm scripts
are low-level and leverage the actual library you want to use (example:"lint": "eslint ./"
)package.json
is a central place to see what scripts are available (alsonpm run
will list all scripts)- When things get too complicated you can always defer to another file (example:
"complex-script": "babel-node tools/complex-script.js"
) npm scripts
are more powerful than one might first think (pre/post hooks, passing arguments, config variables, chaining, piping, etc...)
public static T Time<T>(string op, Func<T> f) | |
{ | |
var sw = Stopwatch.StartNew(); | |
T result = f(); | |
sw.Stop(); | |
Console.WriteLine($"{op} took {sw.ElapsedMilliseconds} ms"); | |
return result; | |
} |
Clojure is an amazingly powerful language. Using it (and watching Rich Hickey videos) has changed the way I think about programming, and the way I code in general. Once I learned the basics of the language, which was a relatively quick process, I fell in love and couldn't look back. I hope this post can help others who are new to Clojure get up and running quickly and painlessly.
This post is opinionated in the sense that I'll suggest certain tools to help those who are new to this scene get on their feet. The things you'll need are:
- Leiningen (pronounced LINE-ing-en) - This is like a package manager, build tool, task manager, and more in one tool. Think npm or nuget, but with more capabilities. There is at least one other build tool for Clojure (boot), but Leiningen is the most widely used.
- JDK - Clojure runs on Java. Throw out any qualms you may have about Java, we aren't coding in Java (though we can through Clojure, and sometimes tha
- High level overview https://yogthos.github.io/ClojureDistilled.html
- An Animated Introduction to Clojure https://markm208.github.io/cljbook/
- Interactive tutorial in a browser https://tryclojure.org/
- Interactive exercises http://clojurescriptkoans.com/
- Clerk notebooks with introductory examples https://github.clerk.garden/anthonygalea/notes-on-clojure
- More interactive exercises https://4clojure.oxal.org/
- Lambda Island tutorials https://lambdaisland.com/
- Functional Programming with Clojure resources https://practicalli.github.io/
These resources (articles, books, and videos) are useful when you're starting to learn the language, or when you're learning a specific part of the language. This an opinionated list, no doubt. I've compiled this list from writing and teaching Clojure over the last 10 years.
- 🔴 Mandatory (for both beginners and intermediates)
- 🟩 For beginners
- 🟨 For intermediates