(defn extraleave | |
[n coll] | |
(->> (repeat coll) | |
(map drop (range n)) | |
(map (partial take-nth n)))) | |
(comment | |
(->> (interleave [1 2 3] [4 5 6]) | |
(extraleave 2)) ;=> ((1 2 3) (4 5 6)) |
#lang racket/base | |
(require data/queue) | |
(provide fork yield done run-threads) | |
(define current-runqueue (make-parameter #f)) | |
(define (fork thunk) | |
(enqueue! (current-runqueue) (lambda () (thunk) (done)))) | |
(define (yield) |
Let's have some command-line fun with curl, [jq][1], and the [new GitHub Search API][2].
Today we're looking for:
There are many articles and discussion threads on the web regarding the nature of Object-oriented (OO) programming. Most of them come at the question from a Programming Language Theory (PLT) perspective, attempting to assert a formal definition of OO programming and objects. I'm not going to do that here. Instead, I'm going to write about objects from an implementation perspective, approaching the subject first from below and then from above.
(ns depr.core) | |
(defn ^:private !! [c] | |
(println "WARNING - Deprecation of " c " in effect.")) | |
(defmacro defn-deprecated | |
[nom _ alt ds & arities] | |
(let [silence? (:silence-deprecations (meta clojure.core/*ns*))] | |
(when-not silence? | |
(!! alt))) |
One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.
Most workflows make the following compromises:
-
Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the
secure
flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection. -
Use production SSL certificates locally. This is annoying
This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.
The script is here:
#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"
(ns shades.lenses) | |
; We only need three fns that know the structure of a lens. | |
(defn lens [focus fmap] {:focus focus :fmap fmap}) | |
(defn view [x {:keys [focus]}] (focus x)) | |
(defn update [x {:keys [fmap]} f] (fmap f x)) | |
; The identity lens. | |
(defn fapply [f x] (f x)) | |
(def id (lens identity fapply)) |
(ns clojure-peg-memoization-example | |
"A followup to Sean Cribbs' presentation on packrat parsers: | |
https://github.com/seancribbs/pwl-chicago-1/ | |
The goal is to show that in an impure language like Clojure we can | |
bolt on memoization after the fact and get the same performance | |
advantage as the Haskell implementation without bending over | |
backwards -- i.e., we maintain the same algorithm structure as a | |
recursive descent parser. |