Skip to content

Instantly share code, notes, and snippets.

View kasimon's full-sized avatar

Karsten Heymann kasimon

View GitHub Profile

fix function - https://github.com/NixOS/nixpkgs/blob/9f087964709174424bca681b600af8ee8e763df5/lib/fixed-points.nix#L19 , https://en.m.wikipedia.org/wiki/Fixed_point_(mathematics) , point where x = f(x) = f(f(f(f....f(x)....)))

rec { a = 1; b = a + 1; } is the same as fix (self: { a = 1; b = self.a + 1; })

builtins.trace - https://github.com/NixOS/nixpkgs/blob/9f087964709174424bca681b600af8ee8e763df5/lib/debug.nix#L4 trace has different flavors, http://hackage.haskell.org/package/base-4.12.0.0/docs/Debug-Trace.html#v:trace all lazy languages have trace

builtins.seq - in lazy languages data is represented as thunks (IF data has not been yet evaluated THEN it's pointer on function that should produce this data ELSE it's pointer on data), builtins.seq forces first layer of data to evaluate (evaluates it to WHNF?), builtins.deepSeq is recursive variant of seq, it forces whole data to evaluate (evaluates it to NF?), (more https://wiki.haskell.org/Seq, https://www.google.com/amp/s/amp.reddit.

@towo
towo / dnsdist.conf
Last active March 8, 2024 23:21
ACL / query restriction for PowerDNS
newServer('127.0.0.1:4201')
addLocal('127.0.0.1:53')
addLocal('10.1.0.1:53', true, true, 0)
addLocal('203.0.113.42:53', true, true, 0)
setACL('0.0.0.0/0')
internalDomains = newSuffixMatchNode();
internalDomains:add(newDNSName("alpha.example.com."))
internalDomains:add(newDNSName("beta.example.com."))
addAction(RegexRule('^(alpha|beta)\\.example\\.com$'), AllowAction())
addAction(AndRule({NotRule(makeRule('10.0.0.0/8')), SuffixMatchNodeRule(internalDomains)}), RCodeAction(dnsdist.REFUSED))
@joepie91
joepie91 / .md
Last active March 17, 2023 18:42
Nix in multi-user mode on a non-NixOS (eg. Debian) system

This post is deprecated!

Its contents have been moved to the NixOS wiki here, where they are being kept up to date. Please follow the instructions there instead!

The original post is below for posterity.

 

 

@ruedesign
ruedesign / thread.py
Last active July 29, 2023 22:12
Python thread sample with handling Ctrl-C
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys, time, threading, abc
from optparse import OptionParser
def parse_options():
parser = OptionParser()
parser.add_option("-t", action="store", type="int", dest="threadNum", default=1,
help="thread count [1]")
@opie4624
opie4624 / annex-cost.sh
Created December 30, 2012 01:12
Calculate git-annex cost based on ping times for remote hosts.
#!/bin/sh
#
PING="/sbin/ping"
PACKET_SIZE=64
PACKET_COUNT=10
PING_INTERVAL=1
TIMEOUT=2
BASE_COST=200