Skip to content

Instantly share code, notes, and snippets.

@nickanderson
nickanderson / is-there-a-bug-in-templating-not-respecting-move_obstructions.org
Created September 24, 2025 16:34
Investigate bug in templating files where move_obstruction is in use but not respected

The original example from Bas:

bundle agent main
{
    methods:
        "" usebundle => create_link();
        "" usebundle => create_template();
}

Say we have some JSON array of objects:

[
    { "name":"Masin", "location":"Berlin"},
    { "name":"Nick", "location":"LFK", "comment": "https://www.reddit.com/r/Lawrence/comments/13udnwx/what_does_lfk_stand_for" },
    { "name":"Ole","location":"Oslo"}
]
@nickanderson
nickanderson / gist:952af3e12501bfddee3bad0d06beec49
Created August 18, 2025 21:05
Org-roam-dailies-capture-templates example
(setq org-roam-dailies-capture-templates
`(
("j" "Journal")
("e" "Email")
("ec" "Compose")
("er" "Response" )
; Work related templates
("w" "Work")
@nickanderson
nickanderson / how-to-write-and-prepare-an-email-to-be-sent-from-org-mode.org
Created July 10, 2025 23:18
How to write and prepare an email to be sent from org-mode

How to write and prepare an email to be sent from org-mode

@fnat@social.coop https://social.coop/@fnat/114830041609939391 was interested in a workflow where he would write an email in org-mode that gets converted to text to be sent out.

@nickanderson
nickanderson / search-and-replace-for-Xresources.org
Last active July 9, 2025 04:22
Search and replace for Xresources with CFEngine 3

CFEngine manage Xscreensaver mode

This example implements search and replace in a file (specifically an Xresources formatted file).

bundle agent __main__
{
  methods:
      "Test data"
        usebundle => init_test_file( $(example.file) );
@nickanderson
nickanderson / getuid-example-avoid-errors.org
Created June 4, 2025 13:39
Get the UID of a user, but only if the user exists as a local user on the system.

Using getuid() to get a users uid avoiding error from call where user does not exist

A question from Wolfgang in #CFEngine:matrix.org

I’m confused. I have a bundle that should only run on one specific host. What confuses me is that CFE tries to evaluate the variables. In that bundle, I have something like “uid” int => getuid(“my-user”), but of course this user does not exist on the other systems. However, cfe shows an error saying that it could not get the uid for that user.

CFEngine is eager to resolve variables (classes in common bundles too), for more read about pre-evaluation.

@nickanderson
nickanderson / example.org
Last active May 16, 2025 19:55
How can you use strings that look like CFEngine variables in CFEngine promises?

You can use $(const.dollar) if you are looking to render a literal $( ) into a file, alternatively you can use backticks.

bundle agent example_subshell_cfengine_files_promise
{
  files:
      "/tmp/using-const.dollar.txt"
        content => "#!/bin/env bash $(const.n)echo $(const.dollar)(hostname)",
        perms => m( "u+rwx" );
@nickanderson
nickanderson / newgist-org-mode-example-tangle-content-multiple-files-header-args.org
Last active April 23, 2025 18:26
Example tangling content to different places based on header arguments

Example for tangling the same content to different places based on header arguments

@nickanderson
nickanderson / CFEngine-bundle-parameters-are-optional.org
Created April 17, 2025 23:00
CFEngine Bundle Parameters Are Optional

Bundle parameters are optional.

Both in the sense of implementation, but also from the perspective of use.

I did not know (or if I did, i don’t even remember forgetting) that bundle parameters, if present are optional. In that, a bundle that has parameters can be called without parameters . However, if you call with non-zero parameters you must supply all (that part I knew).

bundle agent __main__
{
@nickanderson
nickanderson / example.org
Created April 17, 2025 21:08
variable index for masin
bundle agent __main__
{
  vars:
      "stuff" slist => { "some", "thing-s", "that's", "not valid", "variable names"};

      "classic_associative_array[$(stuff)]"
        string => string_upcase("$(stuff)");
}