Use type inference where possible, but put clarity first, and favour explicitness in public APIs.
Almost never annotate the type of a private field or a local variable
All public methods should have explicit type annotations.
| #stop all containers: | |
| docker kill $(docker ps -q) | |
| #remove all containers | |
| docker rm $(docker ps -a -q) | |
| #remove all docker images | |
| docker rmi $(docker images -q) | |
| #remove intermediate containers, use "build --rm" to avoid them |
| ;; :require [clojure.string :as s] | |
| (defn print-logo | |
| " Prints a Cool logo " | |
| [] | |
| (letfn [(fn-str [& args] (s/join \newline args))] | |
| (print (fn-str | |
| "" | |
| "" | |
| "" |
| ;; add the latest git revision to the uberjar file name | |
| (defproject foo "4.3" | |
| ;;.... | |
| :uberjar-name ~(str | |
| "foo-%s" | |
| (try | |
| (str "-" |
| (defn ns-qualified-keys | |
| " | |
| takes a namespace and map of kv and converts it to namespace qualified keys | |
| (ns-qualified-keys 'foo.bar {:port 80}) | |
| ;;=> {:foo.bar/port 80} | |
| " | |
| [ns m] | |
| (into {} | |
| (for [[k v] m] |
| # Adjust Docker Machine Memory+CPU | |
| # http://stackoverflow.com/questions/32834082/how-to-increase-docker-machine-memory-mac | |
| docker-machine stop | |
| VBoxManage modifyvm default --cpus 2 | |
| VBoxManage modifyvm default --memory 4096 | |
| docker-machine start |
| #! /usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| import sys, os, argparse | |
| import logging | |
| import csv | |
| import json | |
| from functools import partial |
Use type inference where possible, but put clarity first, and favour explicitness in public APIs.
Almost never annotate the type of a private field or a local variable
All public methods should have explicit type annotations.
| # /usr/libexec/java_home -X | |
| $ sudo opensnoop -n java_home | |
| UID PID COMM FD PATH | |
| 501 79809 java_home 3 /System/Library/PrivateFrameworks/JavaLaunching.framework/Versions/A/JavaLaunching | |
| 501 79809 java_home 3 /dev/dtracehelper | |
| 501 79809 java_home 4 /System/Library/CoreServices/SystemVersion.bundle//English.lproj | |
| 501 79809 java_home -1 /System/Library/CoreServices/SystemVersion.bundle//Base.lproj | |
| 501 79809 java_home 4 /System/Library/CoreServices/SystemVersion.bundle/English.lproj/SystemVersion.strings | |
| 501 79809 java_home -1 /System/Library/CoreServices/SystemVersion.bundle/English.lproj/SystemVersion.stringsdict | |
| 501 79809 java_home 3 /usr/share/icu/icudt51l.dat |
| (defn fizzbuzz | |
| " | |
| rules - map of number and string ex. {3 \"fizz\" 5 \"buzz\"} | |
| limit - number to count too | |
| " | |
| [rules limit] | |
| (((fn [f] (f f)) | |
| (fn [f] | |
| (fn [x] |
| ;;; https://clojure.org/reference/repl_and_main#_launching_a_socket_server | |
| ;;; -Dclojure.server.repl="{:port 5555 :accept clojure.core.server/repl}" | |
| (defmacro send-forms [host port form & forms] | |
| `(with-open [socket# (java.net.Socket. ~host ~port)] | |
| (let [pw# (java.io.PrintWriter. (.getOutputStream socket#) true) | |
| in# (java.io.BufferedReader. (java.io.InputStreamReader. (.getInputStream socket#))) | |
| forms# (list ~(str form) ~@(map str forms))] | |
| (reduce |