Skip to content

Instantly share code, notes, and snippets.

@nickanderson
nickanderson / select_class.org
Created March 14, 2024 15:10
select_class example
bundle agent __main__
{
  vars:
    # one option for each of 28 days in a month.
    "options" slist => { expandrange( "selected_option_[1-28]", 1 ) };

  classes:
    "selected_option" select_class => { @(options) };
@nickanderson
nickanderson / gourceing-my-org.org
Last active July 9, 2023 18:40
How I generated a gource visualization of some org-files stored in git repositories

I have a long history of using org-mode, but I don’t have a consistent history of tracking it under version control. I have at times and then stopped, I don’t push my git repository anywhere, it does get backed up periodically. Some of my org-mode files get copied around to multiple devices (typically bi-directional sync, but you can get creative with send only and exclusions etc ..). Anyway, I have a few different git repositories that contain org-mode files and I wanted to visualize activity over time. Gource produces a nifty visualization, and you can even interact with it, zooming in, panning around while being able to see user, directory, and file names.

I use this city script to generate videos like https://www.youtube.com/watch?v=b7y0y6sWb2I

#!/bin/bash
set -e
set -u
set -x
@nickanderson
nickanderson / example.org
Last active July 7, 2023 16:44
Example illustrating use of regex_replace() to remove quiet from GRUB_CMDLINE_LINUX_DEFAULT

Example illustrating use of regex_replace() to remove quiet from GRUB_CMDLINE_LINUX_DEFAULT

Use regex_replace() to remove quiet from GRUB_CMDLINE_LINUX_DEFAULT.

bundle agent __main__
{
    methods:
     "init";
     "test";
@nickanderson
nickanderson / example.org
Created July 5, 2023 19:23
How to add custom policy to grant clients access to a custom directory and integrate via cfbs.

How to add custom policy to grant clients access to a custom directory and integrate via cfbs

To grant clients access to a new path via cf-serverd you need an access type promise.

We can create my-custom-access.cf with a server bundle and an access type promise:

bundle server my_custom_access
{
@nickanderson
nickanderson / example-converting-traditional-3.18.3-cfengine-policy-to-cfbs.org
Created June 28, 2023 14:44
org-mode source for Example converting a traditionally managed 3.18.3 policy set to cfbs which was transcluded

Example converting a traditionally managed 3.18.3 policy set to cfbs

Initalizing a traditionally managed policy set

First, we need to initialize a traditional policy set. Let’s start with masterfiles from the 3.18.3 release. This way we can go through the process of migrating to the same version with cfbs. We need to download it and unpack it into the root of our repository.

@nickanderson
nickanderson / org-roam-dailies-capture-templates.org
Created June 15, 2023 19:08
Snippet of my org-roam-dailies-capture-templates

Here is an example of my daily capture templates. My work log (wll) is my most often used capture template. I have many other capture templates for things that recurr on a regular basis, like Meetings. The capture template for a specific meeting includes links to the common attendees individual note pages. These links surface that meeting if I visit an individuals note and run org-roam-buffer.

(setq org-roam-dailies-capture-templates
      `(

        ("w" "work")
        ("wl" "Log")
        ("wll" "Log" entry
         "* %?\n:properties:\n:prior_context: %a\n:end:\n"
@nickanderson
nickanderson / main.cf
Created February 1, 2023 15:42
A simple example for alexfromgalax
# services/main.cf
bundle agent mpf_main
# User Defined Service Catalogue
{
methods:
# Activate your custom policies here
"my_classification";
"my_stuff";
@nickanderson
nickanderson / example.cf
Created January 26, 2023 19:09
preserve old rxdirs behaviro
bundle agent __main__
{
files:
# If you had:
"/path/to/something./"
depth_search => recurse( "inf" ),
perms => mog( "600", "root", "root");
# And you want to have the old rxdirs behavior:
"/path/to/something./"
@nickanderson
nickanderson / cfengine-chocolatey-windows.org
Created January 20, 2023 20:20
CFEngine with Chocolatey on Windows

Note: Windows package management *may* be better handled via integration with Chocolatey and open source package manager for Windows similar to yum or apt-get.

  • Product Name:: 7-Zip 16.04 (x64 edition)
Version
16.04.00.0

Product Name and version (inside the MSI) can be found (or changed) using Orca. http://www.7-zip.org/a/7z1604-x64.msi


@nickanderson
nickanderson / example-namespaces.org
Created January 20, 2023 19:29
Simple example showing CFEngine namespaces
bundle agent __main__
{
   methods:
    "" usebundle => my_bundle("first");
    "" usebundle => default:my_bundle("second");
    "" usebundle => nickanderson:my_bundle("third");
}
bundle agent my_bundle(input)
{