SNIPS.PLAINTEXT.DEV
2025-05-22 - Ignore Git Files with FZF
When using fzf from vim/neovim it lists all git files by default.
To avoid this install `fd` e.g.
doas pkg_add fd
Afterwards change the FZF_DEFAULT_COMMAND and FZF_CTRL_T_COMMAND variables
export FZF_DEFAULT_COMMAND='fd --type f --strip-cwd-prefix'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
Tags: vim neovim fzf fd
2025-03-14 - Operating System Type In Erlang/Elixir
Get the current running operating system in erlang or elixir:
os:type().
Elixir:
:os.type
Tags: erlang elixir os
2024-12-12 - Creating Random Strings in Elixir
To create a random string in Elixir:
Enum.take_random(~c"abcdefghijklmnopqrstuvwxyz", 4) |> to_string
Tags: elixir, random, strings
2024-12-12 - Simple Web Endpoint in Elixir
To spawn a web endpoint in Elixir a short script can be used:
#!/usr/bin/env elixir
Mix.install([:plug, :plug_cowboy])
defmodule Router do
use Plug.Router
plug Plug.Logger
plug :match
plug :dispatch
get "/" do
send_resp(conn, 200, "Hello World\n")
end
end
require Logger
webserver = {Plug.Cowboy, plug: Router, scheme: :http, options: [port: 4000]}
{:ok, _} = Supervisor.start_link([webserver], strategy: :one_for_one)
Logger.info("Server now running on localhost:4000")
Process.sleep(:infinity)
curl localhost:4000
Hello World
Tags: elixir, webserver, phoenix, http, curl
2024-12-02 - Taking Screenshots More Comfortably In i3wm
Tiling window managers like i3 do not provide the same comfort for
taking screenshots as e.g. KDE does.
An example how to take screenshots, copy them to the clipboard (for easy sharing)
and saving them to `~/.screenshots` for later use:
bindsym --release Mod1+Shift+4 exec /home/user/bin/screenshot
#!/bin/sh
SDATE=$(date +%Y-%m-%d-%H%M%S)
SPATH=/home/user/.screenshots
scrot -s - | tee ${SPATH}/${SDATE}.png | xclip -selection clipboard -target image/png
feh ${SPATH}/${SDATE}.png
The `scrot` command takes the screenshot, saves it into the `~/.screenshot` directory
with the date as name, copies the image to your clipboard for pasting
and opens it in a new window.
Tags: i3, screenshot
2024-11-30 - Start Erlang's Observer In iex With Or Without mix
It is sometimes useful to be able to start Erlang's observer tool from iex.
After starting iex with `iex -S mix` in a terminal from within
an Elixir project folder:
Mix.ensure_application!(:observer)
After starting iex with simply `iex` in an a terminal:
Application.ensure_all_started(:observer)
The observer can now be started with `:observer.start()`.
Tags: Elixir, Erlang, iex, mix, observer
2024-11-29 - Display Brightness With xrandr
To change your display brightness with xrandr use this command:
xrandr --output DisplayPort-1 --brightness 0.7
Replace `DisplayPort-1` with your used output.
Use `xrandr` itself to find the correct output.
Use a brightness value between 0 and 1 e.g. 0.7.
Tags: OpenBSD, xrandr, display, brightness
2024-11-29 - Building TailwindCSS On OpenBSD
Currently there is no simple way to build tailwind version 3.x.x via the hex package on OpenBSD.
To use the phoenix framework on OpenBSD in a sane matter follow this steps:
doas pkg_add node
# cd into your phoenix project and install the needed packages via npm
npm install -D tailwind@3
npm install -D @tailwind/forms
# you may have to adjust the version in config/config.exs
# mix will tell you if there is a version mismatch
# now start the application to create the correct dirs and files
mix phx.server
# stop the server with e.g. CTRL+C
Replace the tailwind_os_$arch executable in the _build directory
of your Phoenix application with this script:
#!/bin/sh
npx tailwindcss "$@"
Make the file executable with `chmod +x`.
Running your phoenix application should now work with the correct styling.
Tags: Elixir, OpenBSD, TailwindCSS, Phoenix