Skip to content

Instantly share code, notes, and snippets.

View cafkafk's full-sized avatar
🍮

Christina Sørensen cafkafk

🍮
View GitHub Profile
Running phase: unpackPhase
@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking source archive /nix/store/4vshbg1rjirlffg7n6wkx921yfmzff6q-daq-2.2.2.tar.gz
source root is daq-2.2.2
setting SOURCE_DATE_EPOCH to timestamp 1499285530 of file daq-2.2.2/ChangeLog
Running phase: patchPhase
@nix { "action": "setPhase", "phase": "patchPhase" }
Running phase: updateAutotoolsGnuConfigScriptsPhase
@nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase" }
Updating Autotools / GNU config script to a newer upstream version: ./config.sub
@cafkafk
cafkafk / battery-notification.nix
Last active August 24, 2024 03:21
Simple battery notification for nixos config
{
systemd.user.services."battery-low" = {
enable = true;
description = "Notify user if battery is below 10%";
partOf = ["graphical-session.target"];
wantedBy = ["graphical-session.target"];
serviceConfig = {
Type = "simple";
ExecStart = pkgs.writeShellScript "battery-low-notification"
''
#!/usr/bin/env fish
# https://sre.google/sre-book/eliminating-toil/
rm "/tmp/nix-update-$argv[1]" -r
cd $(zoxide query nixpkgs)
git worktree remove "/tmp/nix-update-$argv[1]"
git stash
git switch master
git pull
set bump "$(nix run nixpkgs#nix-update -- "$argv[1]" &| rg -o -- '\d+\.\d+\.\d+ -> \d+.\d+\.\d+')"
-- This is the amount of cookies
>> servings: 36
>> cookies: 36
>> time required: 30 minutes
>> prep time: 10 minutes
>> cook time: 10 minutes
>> source: https://joyfoodsunshine.com/the-most-amazing-chocolate-chip-cookies/
>> course: desert
-- Serving: 1cookie | Calories: 183kcal | Carbohydrates: 26g | Protein: 2g | Fat: 8g | Saturated Fat: 5g | Cholesterol: 27mg | Sodium: 153mg | Potassium: 31mg | Fiber: 1g | Sugar: 18g | Vitamin A: 197IU | Vitamin C: 1mg | Calcium: 24mg | Iron: 1mg
@cafkafk
cafkafk / nix-fmt.patch
Last active September 23, 2023 03:21
Result of applying `nix fmt` which does treewide rustfmt (https://github.com/eza-community/eza/pull/405#discussion_r1334671749)
diff --git a/src/options/filter.rs b/src/options/filter.rs
index 8a63dbe0..b22881c3 100644
--- a/src/options/filter.rs
+++ b/src/options/filter.rs
@@ -28,10 +28,14 @@ impl SortField {
/// Returns the default sort field if none is given, or `Err` if the
/// value doesn’t correspond to a sort field we know about.
fn deduce(matches: &MatchedFlags<'_>) -> Result<Self, OptionsError> {
- let Some(word) = matches.get(&flags::SORT)? else { return Ok(Self::default()) };
+ let Some(word) = matches.get(&flags::SORT)? else {
@cafkafk
cafkafk / ofbake.sh
Created August 22, 2023 10:57
ofbake - watch and ping when ofborg is done
#!/usr/bin/env sh
gh pr checks $1 --watch && notify-send "ofborg is done cooking $1" || notify-send "ofborg burned $1"
@cafkafk
cafkafk / Cargo toml version.txt
Created August 22, 2023 08:20
Cargo toml version
(?!^version = .)([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?
@cafkafk
cafkafk / nix-dollar.patch
Created August 3, 2023 12:06
Add __dollar so you can haskell your nix even more!
diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y
index 201370b90..4b26af623 100644
--- a/src/libexpr/parser.y
+++ b/src/libexpr/parser.y
@@ -353,6 +353,7 @@ void yyerror(YYLTYPE * loc, yyscan_t scanner, ParseData * data, const char * err
%left AND
%nonassoc EQ NEQ
%nonassoc '<' '>' LEQ GEQ
+%nonassoc '$' DOL
%right UPDATE
@cafkafk
cafkafk / get_ip.sh
Created July 22, 2023 13:55 — forked from LozanoMatheus/get_ip.sh
Get Linux IP without any tool
#!/usr/bin/env bash
## Get the primary and secundary IPs
awk '/\|--/ && !/\.0$|\.255$/ {print $2}' /proc/net/fib_trie
## Get only the primary IPs
awk '/32 host/ { print i } {i=$2}' /proc/net/fib_trie
seq 100 | cksum | perl -lpe '$_=unpack"B*"' | rg --pcre2 '(.+)(?=.*\1)' -o | sort | tail -n 1 | wc -c | xargs -n 1 bash -c 'echo 2 ^ $1' args | bc