LazyVim

Summary

Notes taken on my learnings and usage of LazyVim.

Sources

LazyVim for Ambitious Developers

Dashboard Mode (lazyvim only)

The menu mode that opens when you open up Lazyvim without a file.

Normal Mode

<count><verb><count><motion> - structure of standard command

" - Open the registers mini-mode for pasting from
s - seek mode, select text that is visible
f - find mode
F - backwards find mode
t - To mode

[Read More]

Ranking Myself With Glicko-2

Introduction

I’ve recently started playing Magic the Gathering and have been experimenting with a few decks to try and learn the game better and see which style(s) of decks I like to play. In order to do so I’m playing practice matches against myself. Despite my best efforts, one of the decks I’m very excited about, the Bloomburrow squirrel deck, has lost most of the practice matches I’ve played against myself.

[Read More]

Things I Like About Nim

Method Call Syntax

In Nim, a.f(b) is really just syntactic sugar for f(a, b). Note: they look like methods but aren’t attached to the type/object at all. Which function to call will be figured out at compile time, just like normal function calls.

You can use this to implement pseudo extension methods on standard types like strings:

import
  nim_utils/files,
  os,
  strformat

proc makeBackup(filename: string) =
  let backupPath = fmt"{filename}.bak"
  case filename.fileType
  of ftFile, ftSymlink:
    copyFile(filename, backupPath)
  of ftDir:
    copyDir(filename, backupPath)
  else:
    raise newException(IOError, fmt"Cannot make backup of {filename}")


for f in @["fstab", "systemd"]:
    fmt"/etc/{f}".makeBackup() # Same as makeBackup(fmt"/etc/{f}")

You can also use this to chain calls together nicely:

[Read More]

Ocaml Memory Model

Non-Atomic Variables

  var1: [t1 -> v1; t2 -> v2]

where var1 is the name of the variable, tx are timestamps, and vx are the values of the variable at those timestamps.

Note that t(n+1) must be greater than t(n)

Domains

Domains are separate spheres of execution. Each thread would have their own Domain, for instance.

Frontier

Domains have a frontier, which establishes which variables it can see at which timestamp.

  d1: [var1 -> t1; var2 -> t3; var3 -> t7]

where d1 is the name of the domain, varx are variable names, and tx are timestamps

[Read More]

Unification Algorithm

Unification Algorithm

    type term =
    | Var of string
    | Term of string * term list

You either have a type variable with a name, or a type constructor with a name and a list of argument

Unification takes a list of term pairs which have to be made matching.

Unification returns a list of substitutions, where a substitution is a pair of a string and a term, aka the variable name that should be substituted with the term.

Steps for unifying two terms

Try to match

[Read More]

OCaml Effects

I’ve been interested in algebraic effects in programming languages for a while, but they’ve been theoretical-only for a while. That’s soon to change though!

OCaml early on adopted algebraic effects and handlers as a way to implement concurrency, something that had been lacking in the language until now. But changing the langugage’s memory model, runtime, garbage collector, etc. proved to be a long task.

OCaml 5.0 is on the horizon at last and includes an implementation of algebraic effects. Unfortunately, I couldn’t find any good tutorials on the version of effect handlers in 5.0. I found a really good tutorial from 5 years ago that was based on a proposed version of OCaml effects, but nothing modern.

[Read More]

Terminal Setup

A lot of people at work have been asking me how I set up my terminal, so I wrote this up to send to them. Hope you enjoy!

Install ZSH

The shell I use is zsh. To install it, follow these instructions

Install oh-my-zsh

oh-my-zsh is a plugin/theming library thingie for zsh.

Follow these instructions to install

Make sure to take a look at the plugins and enable any that might be useful for you. I’m a big fan of colored-man-pages. Man pages become way easier to read when they have different colors, not just black and white.

[Read More]

S3 on Flashblade

I currently work for a company called Pure Storage. One of their products is called Flashblade. I couldn’t find any examples on how to use Flashblade’s S3 capabilities programmatically anywhere online, so I’m putting this out to hopefully help people realize they can move their object store into their data center with very little changes to their code.

Code Snippets

Most of the work with the libraries I’ve used involves figuring out how to get the client configured properly. Once that’s done, all of the methods work just like they do with Amazon S3.

[Read More]
Tags: tech programming code 

Programming Articles and Talks

Here’s a collection of talks or articles that I really enjoy.

The Error Model

Joe Duffy describes the error model in an experimental programming language that he worked on. Starts off by describing different ways that programming languages give programmers to express and deal with errors. He discusses the pros and cons of each strategy, and then goes on to describe how they designed around those problems to create something truly unique.

[Read More]
Tags: lists programming 

When to Use Programming Languages

Java

  • Willing to take a small speed decrease in order to have a much better time programming than C/C++
  • Need to interface with <Obscure Technology>. Because Java probably has a library for it

Kotlin

  • Want/need to use Java libraries but want to feel modern

Groovy

  • I want to write a version of Java that gets rid of everything good about Java while keeping all of the bad

C

  • Need the maximum amount of speed possible

C++

  • Need the maximum amount of speed possible while also having the maximum number of language features that don’t fit together

Javascript

  • Need to write something quick for the browser

Typescript

  • Need to write something large for the browser

Python

  • Short scripts, one-offs
  • Want to have a good time programming while not caring about speed or ease of refactoring

Go

  • Want the power of concurrency, but don’t want to actually learn concurrency

Clojure

  • Want/need to use Java libraries but are a hipster
  • Rich Hickey is my spirit animal
  • Seriously though, Clojure is really good for processing data. It has a lot of functions in the standard library for manipulating lists and maps. It’s my tool of choice when working with large JSON files.

Rust

  • I’m a sub and I want my compiler to be the dom

Haskell

  • Want to prove that all those years of mathematics were useful
  • Want to feel superior to the plebs that can’t understand your beautiful monads

OCaml

  • Want to use a high-level language but am intimidated by Haskell
  • Want a functional language with the opportunity to use imperative programming without having to wrap all values in a ThisIsImpureDontLetItContaminateThePurity monad

PHP

  • No
  • Just no