#!/usr/bin/env bash | |
trap 'kill $(jobs -pr) 2>/dev/null' SIGINT SIGTERM EXIT | |
browser=chromium-browser | |
python3 -m http.server & | |
$browser "http://localhost:8000/$1" 2>/dev/null & | |
browserpid=$! |
from timeit import default_timer | |
class MeasureTime(object): | |
""" | |
Easily measure the time of a Python code block. | |
>>> import time | |
>>> with MeasureTime() as m: | |
... time.sleep(1) | |
Elapsed time: 0 m and 1.00 s |
#!/usr/bin/planck | |
(ns deploy.core | |
(:require [cljs.reader :refer [read-string]] | |
[planck.shell :as shell])) | |
(defn sh [& args] | |
(let [result (apply shell/sh args)] | |
(if (= 0 (:exit result)) | |
(:out result) | |
(throw (ex-info (:err result) {}))))) |
Sent by the Pragmatic Programmers, LLC. • 9650 Strickland Rd Ste 103-255• Raleigh NC 27615 - Feb. 21st, 2018
- Rely on your REPL. Clojure (like other LISP languages) intends to provide a "live" development experience where you are actively manipulating and testing the program while you develop the code. To take full advantage of Clojure, it's essential to work in a development environment that allows you to interactively evaluate parts of your code while you develop. We are fortunate to have a variety of tool choices in Clojure that can satisfy those demands.
- Maps, not Objects. Developers coming from object-oriented languages are likely to look for the ability to create classes or objects to hold their data. Clojure takes a more direct and flexible approach to data, primarily storing information attributes in heterogenous maps. Rather than providing class-specific interfaces, Clojure provides a single generic data interface for creating, accessing, and transforming att
(require '[criterium.core :refer [quick-bench]]) | |
(require '[clojure.core.reducers :as r]) | |
(import '[java.util HashMap Collections Map] | |
'java.util.concurrent.atomic.AtomicInteger | |
'java.util.concurrent.ConcurrentHashMap) | |
(set! *warn-on-reflection* true) | |
;; 500k maps with the same key. value are overlapping 1/5 of the time. | |
(def data | |
(into [] |
(require '[clojure.set :as set]) | |
(def info | |
[{:year 2017 | |
:month 4 | |
:data "x"} | |
{:year 2017 | |
:month 4 | |
:data "y"} |
If you're running a Rails app in Google App Engine's flexible environment, it takes a bit of setup to get to a rails console attached to your deployed environment. I wanted to document the steps for my own reference and also as an aid to others.
-
Open the Google App Engine -> instances section of the Google Cloud Platform (GCP) console.
-
Select the "SSH" drop-down for a running instance. (Which instance? Both of my instances are in the same cluster, and both are running Rails, so it didn't matter for me. YMMV.) You have a choice about how to connect via ssh.
-
Choose "Open in browser window" to open a web-based SSH session, which is convenient but potentially awkward.
-
Choose "View
gcloud
command" to view and copy agcloud
command that you can use from a terminal, which lets you use your favorite terminal app but may require the extra steps of installing thegcloud
command and authenticating thegcloud
command with GCP.
-
Rich Hickey is frequently quoted as saying:
You can reach a point with Lisp where, between the conceptual simplicity, the large libraries, and the customization of macros, you are able to write only code that matters. And, once there, you are able to achieve a very high degree of focus, such as you would when playing Go, or playing a musical instrument, or meditating. And then, as with those activities, there can be a feeling of elation that accompanies that mental state of focus.
A list of commonly asked questions, design decisions, reasons why Clojure is the way it is as they were answered directly by Rich (even when from many years ago, those answers are pretty much valid today!). Feel free to point friends and colleagues here next time they ask (again). Answers are pasted verbatim (I've made small adjustments for readibility, but never changed a sentence) from mailing lists, articles, chats.
How to use:
- The link in the table of content jumps at the copy of the answer on this page.
- The link on the answer itself points back at the original post.