Skip to content

Instantly share code, notes, and snippets.

Avatar
🦞

Jeff Kreeftmeijer jeffkreeftmeijer

🦞
View GitHub Profile
View subshell.adoc

Subshells

A subshell creates a separate instance of the command processor, or a subprocess of the parent shell. Although a subshell is started in its parent’s working directory, directory changes made within the subshell don’t carry over to its parent. This makes subshells ideal for running one-off commands in a different directory:

$ pwd
/Users/jeffkreeftmeijer/rust/conway/
$ (cd www && npm install)
[...]
$ pwd
/Users/jeffkreeftmeijer/rust/conway/
View vim-macros.adoc

Vim Macros

To record a macro, press q in normal mode, followed by a paste registry to store the macro in. To define a quick macro to use a couple of times, I usually use the q registry, meaning I type qq. Vim will tell you you’re currently recording a macro in the status line.

--recording @q

Vim will now record your commands to be used later. For example, to convert a markdown-style link ([Jeff Kreeftmeijer](https://jeffkreeftmeijer.com)) to an asciidoc-style one (Jeff Kreeftmeijer) one, the recorded macro looks like this [1]:

f(di(F[Pa:^[f(xx

1. A subsitution might be a better fit for this specific case
View cargo-install-locked.adoc

cargo install --locked

While installing cargo-generate I ran into an error compiling caused by missing type annotations in cargo itself.

link:e0283.txt[]

An already-closed issue in Cargo explained that the issue originated in the serde crate, and was already resolved. While waiting for a patched release, users were advised to use cargo install --locked.

View generate
ffmpeg -i nightfall.mov -filter_complex "fps=10,scale=960:-1" nightfall.gif
View communication-policy.adoc

Embrace email, mute Slack. A policy for handling incoming messages

View rocket_ship.gleam
fn count_down() {
"3... 2... 1..."
}
fn blast_off() {
"BOOM!"
}
pub fn launch() {
[
@jeffkreeftmeijer
jeffkreeftmeijer / README.md
Last active Dec 29, 2020
Visualising recursive function calls in Elixir
View README.md

Visualising recursive function calls in Elixir

For SICP Exercise 1.14 in Elixir, we'll first implement the count_change/1 function, which calculates how many different ways there are to make change using half-dollars (50 ¢), quarters (5 ¢), dimes (5 ¢) and pennies (1 ¢) for any given amount of money.

iex -r counting_change.exs
Erlang/OTP 23 [erts-11.0.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]
View .ctags
--exclude=node_modules
--langdef=Elixir
--langmap=Elixir:.ex.exs
--regex-Elixir=/^[ \t]*def(p?)[ \t]+([a-z_][a-zA-Z0-9_?!]*)/\2/f,functions,functions (def ...)/
--regex-Elixir=/^[ \t]*defcallback[ \t]+([a-z_][a-zA-Z0-9_?!]*)/\1/c,callbacks,callbacks (defcallback ...)/
--regex-Elixir=/^[ \t]*defdelegate[ \t]+([a-z_][a-zA-Z0-9_?!]*)/\1/d,delegates,delegates (defdelegate ...)/
--regex-Elixir=/^[ \t]*defexception[ \t]+([A-Z][a-zA-Z0-9_]*\.)*([A-Z][a-zA-Z0-9_?!]*)/\2/e,exceptions,exceptions (defexception ...)/
--regex-Elixir=/^[ \t]*defimpl[ \t]+([A-Z][a-zA-Z0-9_]*\.)*([A-Z][a-zA-Z0-9_?!]*)/\2/i,implementations,implementations (defimpl ...)/
--regex-Elixir=/^[ \t]*defmacro(p?)[ \t]+([a-z_][a-zA-Z0-9_?!]*)\(/\2/a,macros,macros (defmacro ...)/
View system_stack_error.rb
class Foo
def foo
puts "ok!"
end
end
Foo.prepend(Module.new do
def foo
puts "prepend!"
super