Fleeting thougths, bits of information so I don't forget and loop.

May 10, 2022

lisp asdf

Switch the current working directory in the REPL

If you start a REPL in the wrong directory, you can switch it by using UIOP.

UIOP is the portability layer of ASDF, supplying an abstraction on top of different implementations or OS'es.

For example, to change to a new project do:

(uiop:chdir "~/lisp/fangorn/")

Make your own packages available to Quicklisp

In Lisp it's quite common to have your own helper libraries, which are packaged as ASDF packages. To be able to use your libraries in other projects, you need to let ASDF know how to find them.

First create the directory ~/.config/common-lisp/source-registry.conf.d/

There create a file with any name of your choice but with the type conf, for instance 50-petar-lisp.conf.

In this file, add the following line to tell ASDF to recursively scan all the subdirectories under /home/petar/lisp/ for .asd files: (:tree "/home/petar/lisp/").

May 9, 2022


Template for a new Common Lisp Project

To easily start a new Common Lisp project, I'm making use of the CL-Project from the famed Lisper Eitaro Fukamachi.

You can either install it through roswell with ros install cl-project or through the use of Quicklisp with ql:quickload "cl-project").

The benefit of install it through Roswell is that you also get a binary.

To create a project through the REPL:

(cl-project:make-project #p"lisp/cl-sample/"
  :author "Eitaro Fukamachi"
  :email "e.arrows@gmail.com"
  :license "LLGPL"
  :depends-on '(:clack :cl-annot))

Or by using the binary:

make-project /home/user/common-lisp/sample \
    --name sample \
    --description "sample project." \
    --author "Your name" --license LLGPL \
    --depends-on alexandria split-sequence`

April 14, 2022


Cargo modules

Today I learned about the cargo-modules, a cargo plugin which shows you an overview of your crates modules.

I like to check the tree and my public interface with:

cargo modules generate tree --with-types

January 2, 2022

command-line fish

November 15, 2021

lisp ai

From Lisp to Python, but why Peter?

Peter Norvig is a well-known educator on A.I. and used to be one of the key figures in the Lisp movement.

His books used to use Lisp in their exercises, but he switched to Python at some point. Today, I came across the Lex Fridman podcast, where he interviewed Peter Norvig and asked him why he made that change.

He gives a surprisingly simple answer at the 43-minute mark.

I was expecting deeper reasons, but his students were having difficulty grasping Lisp, and a questionnaire showed that Python mimicked the pseudocode from the book the most. That's it.

In the short amount of time he had to educate them on A.I., he could not spare the time to educate them on Lisp.

Coincidentally, I also came across this gem at smuglispweeny blog:

At ILC 2002 former Lisp giant now Python advocate Peter Norvig was for some reason allowed to give the keynote address like Martin Luther leading Easter Sunday mass at the Vatican and pitching Protestantism because in his talk Peter bravely repeated his claim that Python is a Lisp.

When he finished Peter took questions and to my surprise called first on the rumpled old guy who had wandered in just before the talk began and eased himself into a chair just across the aisle from me and a few rows up.

This guy had wild white hair and a scraggly white beard and looked hopelessly lost as if he had gotten separated from the tour group and wandered in mostly to rest his feet and just a little to see what we were all up to. My first thought was that he would be terribly disappointed by our bizarre topic and my second thought was that he would be about the right age, Stanford is just down the road, I think he is still at Stanford -- could it be?

"Yes, John?" Peter said.

I won't pretend to remember Lisp inventor John McCarthy's exact words which is odd because there were only about ten but he simply asked if Python could gracefully manipulate Python code as data.

"No, John, it can't," said Peter and nothing more, graciously assenting to the professor's critique, and McCarthy said no more though Peter waited a moment to see if he would and in the silence a thousand words were said.

August 1, 2021


Add aliases for your Rust project

I was looking at the Monkey language implementation done by Lauren Tan and noticed a .cargo/config.toml file in the project directory. In it was a convenient alias for her project:

dev = "watch -x check -x test"

This way, we can run cargo dev, which will run a check, which is not a build but catches a lot of errors quickly. The test is for those doing TDD because it will run the tests after every change. Convenient!

August 1, 2021


Changing working directory in tmux

I tend to keep a long-lived tmux session per project that I'm working on. When I want to start a new project though, it carries the old working directory with it. I keep forgetting what I need to do to type it, so hopefully this TIL makes me remember it for the next time.

To switch the current working directory, do a :attach -c <newdir>. And to do it it even more easily, I bound it in my tmux configuration to Meta-w:

bind M-w attach -c "#{pane_current_path}"

SSH Tunnels

I often rely on SSH tunnels to forward remote ports locally. For example, to control my remote installation of Resilio Sync. There is a lot of flags you can set, but these are the flags that work best for me:

ssh -CqTnNf -L 8889:localhost:8888 user@example.com

In this example, I forward the remote localhost:8888 port to my local 8889. The flags do the following:

  • C: Compress the data.
  • q: Silent modus.
  • T: Disable pseudo-tty allocation.
  • n: Prevent reading stdin.
  • N: No remote commands, just forwarding.
  • f: Run in the background.
  • L: Specifies the forward.

Now, if you want to exit the tunnel, you could kill SSH pkill ssh, but this will kill all your SSH connections. I multiplex my connections and can run: ssh -O exit user@example.com. You would need this in your ~/ssh/.config to be able to do that as well:

Host *
  ControlMaster auto
  ControlPath ~/.ssh/sockets/%r@%h-%p

Rust project templates

Rust never stops to amaze me with its command-line tools and today I found out about cargo-generate which enables you to setup a repository which will function as a project template for Rust.

As an example, to pull down the repository and start a new project, you would do:

cargo generate --git https://github.com/githubusername/mytemplate.git --name myproject

Staying up-to-date with Rust

I have this tick where I continuously check that my tools are running the latest version. I guess you could call it a form of FOMO.

Luckily, Rust has me covered with two packages which check that for me.

cargo-outdated which check that your project dependenies are up-to-date. And cargo-update which checks that your Rust executables, like cargo-edit are running the latest version.

It will even update itself!

June 9, 2021


Do not get to shame

The code I'm still ashamed of is an excellent read, reminding us of our responsibility as software developers.

It also reminded me of an experience we had with Bread & Pepper, the web agency we ran from 2009-2013. A government agency approached us to build an iPhone app where you could overlay your face on Einstein. We could have used the money but decided to be frank and tell them that the idea was ridiculous and a waste of public funds.

After a few weeks, we received the response that we were the only ones who told them the truth and picked us to continue the conversation on how to achieve their goals. We got rewarded for our honesty that day.

I tend to pay attention to the feeling of shame, its trying to tell me that I did something against my morals.

Reminder that shame is a strong indicator that you messed up. Be morally strong and avoid that feeling of shame.

June 6, 2021


Tombstones for code

An interesting 5-minute talk called Isn't That Code Dead? where David Schnepper talks about a technique called "Tombstones."

The simple technique where you place a marker in your code which logs if it's ever called. After a while, you check your logs and see what markers are untouched, giving you the confidence to remove that code.

Great way to find dead code in situations where the compiler can't help you, for example interfaces exposed on the network.

Tombstones is a simple technique which can help you reduce the lines of code by eliminating dead code.

May 24, 2021


Rust tooling came a long way

I bought the Hands-on Rust and needed to setup my editor (Visual Studio Code) to start working on my 2D dungeon crawler. Choose Rust Analyzer and could not be more impressed with the experience.

Also impressed with some of the Cargo helper tools, like cargo-edit to manage dependencies, cargo-audit to check for vulnerabilities and cargo-expand to expand macro's.

2021 is a great year to start learning Rust. Both the ecosystem and learning materials have reached a high level of maturity.

May 23, 2021

management book

Ask Iwata

Ask Iwata was a quick read, a loosely connected series of short essays where I read a lot of things which resonated with me.

On my business card, I am a corporate president. In my mind, I am a game developer. But in my heart, I am a gamer.

As you move to management, you must never loose focus on the core values of your business. It's your role to create an environment which inspires towards those goals and that empowers your team to do their best work.

Management frameworks and processes often miss this point, where they serve the manager instead of the team.

As a manager you can never loose touch with the process of creation. It's your job to create an environment where that can thrive.