Escape with Spacemacs in Tmux

21 October 2020

I’ve occasionally been using a SSH session from my Pixel phones for years to login to my servers and write Clojure code in Emacs. I’d often run into an issue where I find myself having a weird time switching between NORMAL and INSERT modes when I’d hit ESCAPE quickly and try to move the cursor.

Googling my random problems is a favorite pastime, and I’ve finally stumbled upon an article about tmux and vim escape key. I learned that it’s probably been tmux sporadically eating my ESCAPE key, so I’ve tried disabling the built-in delay by adding to my .tmux.conf:

set -g -s escape-time 0


Clojure Core Logic for a Puzzle

11 May 2020

Lock Puzzle

I saw a puzzle pop up on Facebook a couple weeks ago, and it looked like a fun exercise for core.logic, since the puzzle simply requires keeping track of some constraints and reconciling them to one answer.

I had previously tinkered with the core.logic primer and I referred back to it to complete this little puzzle. I had originally coded some more complete rules about exclusion of some values which could have been implied by the puzzle, but I found they could be dropped and still get down to one answer. I started from the entire problem space of all digits and added the constraints to watch and verify each constraint’s effects.

(ns scratch.2020-05
  (:require [clojure.core.logic :as l]))

(l/run* [a b c]
  ;; all digits 0-9
  (l/membero a (range 10))
  (l/membero b (range 10))
  (l/membero c (range 10))
  ;; 6 8 2 one digit is right and in its right place
  (l/conde
    [(l/== a 6)]
    [(l/== b 8)]
    [(l/== c 2)])
  ;; 6 1 4 one digit is right but in the wrong place
  (l/conde
    [(l/membero a [1 4])]
    [(l/membero b [6 4])]
    [(l/membero c [6 1])])
  ;; 206 2 digits are right, but both are in the wrong place
  (l/conde
    [(l/membero a [0 6])
      (l/membero b [2 6])
      (l/membero c (remove #{2 0 6} (range 10)))]
    [(l/membero a [0 6])
      (l/membero c [2 0])
      (l/membero b (remove #{2 0 6} (range 10)))]
    [(l/membero b [2 6])
      (l/membero c [2 0])
      (l/membero a (remove #{2 0 6} (range 10)))]
      )
  ;; 3 8 0 one digit is right but in the wrong place
  (l/conde
    [(l/membero a [8 0])]
    [(l/membero b [3 0])]
    [(l/membero c [3 8])])
  ;; 7 3 8 all the digits are wrong
  (l/membero a (remove #{7 3 8} (range 10)))
  (l/membero b (remove #{7 3 8} (range 10)))
  (l/membero c (remove #{7 3 8} (range 10))))
;; => ([0 4 2])


Reagent Front End

16 March 2020

For the past couple days, I’ve started playing with Reagent to do a bit of React programming. I used the Reagent-frontend template for leiningen to get my start. Within a day or two, I had managed to string together a useful little toy application. It only took me a couple hours to get my next toy application put together. Each application is a mere single-page application for doing a single, simple task on a mobile device. It’s a lot of fun, and this opens the door for quickly implementing any toy I want.


Advent of Code

14 December 2019

For the second year I’m taking part in the Advent of Code with friends and coworkers. I’m using Clojure again this year.

The Advent of Code is a story and series of puzzles released as 2 parts daily. There’s a community of people competing at various levels to complete the puzzles faster than others. I was keeping up fine for the first 7 days or so, but I eventually fell behind like many people. Fortunately, everyone can continue to work at our own pace. The puzzles from previous years continue to be available.

I’m happy to find that I’m having an easier time with Clojure this year, and I’m more easily able to use it to describe the algorithms instead of struggling with the language. I publish my code to Github.


All the Posts

October 2020

May 2020

March 2020

December 2019

March 2018

February 2018

January 2018