Skip to content

Instantly share code, notes, and snippets.

View florianb's full-sized avatar
⚗️
Brewing some Elixir

Florian Neumann florianb

⚗️
Brewing some Elixir
View GitHub Profile
@florianb
florianb / keymap.json
Created June 26, 2025 11:28
TextMate-like Tabbing for Zed
// Zed keymap
//
// For information on binding keys, see the Zed
// documentation: https://zed.dev/docs/key-bindings
//
// To see the default key bindings run `zed: open default keymap`
// from the command palette.
[
{
"context": "Editor && vim_mode == insert && showing_completions",
@florianb
florianb / livebook.service
Last active May 6, 2024 11:37
Livebook.dev Systemd Service
[Unit]
Description=Livebook Server
After=docker.service
Requires=docker.service
[Service]
User=livebook
Group=livebook
Restart=always
ExecStartPre=-/usr/bin/docker stop livebook
@florianb
florianb / clocks.typ
Last active November 5, 2023 16:08
Educational Clock rendering in Typst without external dependencies
#let transform(coordinates, x: 0mm, y: 0mm) = {
(coordinates.at(0) + x, coordinates.at(1) + y)
}
#let coordinates(radius, degree) = {
let sin = calc.sin(degree)
let cos = calc.cos(degree)
(radius * sin, radius * cos)
}
@florianb
florianb / util.ex
Last active October 25, 2023 13:24
Camelize/Underscore Util for Map keys in Elixir
defmodule Util do
@moduledoc """
This module contains utilities.
"""
@doc """
Converts the keys of the given map to camelized strings.
## Examples
@florianb
florianb / task.yml
Created January 29, 2021 10:17
Nested Ansible Loop
- debug: I try to loop over the top level and the 2nd level
msg: "{{ item.manufacturer }} {{ item.???.carname }} {{ item.???.carattributes }}"
loop: "{{ manufacturers | dict2items(key_name= 'manufacturer') }}"
@florianb
florianb / design_document.ex
Last active June 16, 2020 10:56
Draft for Elixir-based CouchDb design documents in Erlang.
defmodule DatabaseServices.CouchDb.DesignDocument do
@moduledoc false
alias DatabaseServices.CouchDb.Document
def put(module, opts \\ []) do
couch_keys = ["_id", "_rev", :_id, :_rev]
view_name = module |> extract_ddoc_name()
id = "/_design/#{view_name}"
@florianb
florianb / dd-ix.json
Last active June 8, 2020 22:05
Example View for CouchDb
{
"_id": "_design/nvd_1_0",
"id": "_design/nvd_1_0",
"key": "_design/nvd_1_0",
"views": {
"cve_sev": {
"map": "function(doc) {\n // first extract what we want to use\n const vendors = doc.cve &&\n doc.cve.affects &&\n doc.cve.affects.vendor &&\n doc.cve.affects.vendor.vendor_data;\n\n // since we can't be sure vendor_data does exist\n // let's check if it's really an array\n if (Array.isArray(vendors) === false)\n return; // if not just return and proceed with the next document\n\n // iterate through every \"vendor\" in that array\n vendors.forEach(vendor => {\n // let's remember the vendor name\n const vendorName = vendor.vendor_name;\n // let us also unwrap the product_data\n const products = vendor.product &&\n vendor.product.product_data;\n \n // again, if products is no array\n if (Array.isArray(products) === false)\n return; // return and proceed with the next vendor\n \n products.forEach(product => {\n //
@florianb
florianb / test.js
Created April 14, 2020 16:57
Experimental test file
// "A" works
// Supplying a locale has no effect
// Saving the js file as LATIN-x/UTF8 (wo BOM) works
// Saving the js file as UTF8BOM, UTF16LE, UTF16BE does not work
var t = "Ä".toLowerCase("de"); // fails
print(t)
quit(1)
@florianb
florianb / 10-docker-default.ini
Last active February 12, 2020 18:11
couchdb-3-rc1
; CouchDB Configuration Settings
; Custom settings should be made in this file. They will override settings
; in default.ini, but unlike changes made to default.ini, this file won't be
; overwritten on server upgrade.
[chttpd]
bind_address = any
[httpd]
@florianb
florianb / kubedump.sh
Created November 3, 2018 13:33 — forked from negz/kubedump.sh
Dump Kubernetes cluster resources as YAML
#!/usr/bin/env bash
set -e
CONTEXT="$1"
if [[ -z ${CONTEXT} ]]; then
echo "Usage: $0 KUBE-CONTEXT"
exit 1
fi