Skip to content

Instantly share code, notes, and snippets.

View agumonkey's full-sized avatar

gum agumonkey

  • NONE
  • Dark side of the moon @ ['tkf8-2-1', 'ay21-3', '3263-827']
View GitHub Profile
@heppu
heppu / ARCH_INSTALL.MD
Last active February 27, 2022 17:01
Installing Arch with GPT, dm-crypt, LUKS, LVM and systemd-boot

Create bootable USB

dd bs=4M if=/path/to/archlinux.iso of=/dev/sdx status=progress oflag=sync

Boot from USB and set prepare system

loadkeys <your-keymap>
anonymous
anonymous / nested-cont.scm
Created August 18, 2016 11:12
nested continuations are tricky (see Alan Bawden)
(define (cc k) (call-with-current-continuation k))
(display (format ">>> ~s\n" (- 10 (cc (lambda (k) (+ 1 (+ 2 (k 10))))))))
(let ((k (cc (lambda (bind) (lambda (x) (+ 1 (cc (lambda (k) (bind k))))))))) (k 10))
(let ((k (cc (lambda (bind)
(lambda (x)
(+ 1 (cc (lambda (k)
(bind k)))))))))
(k 10))
#lang racket
;; A solver for the following puzzle:
;; Given 5 integers a, b, c, d, and e,
;; find an expression that combines a, b, c, and d with arithmetic operations (+, -, *, and /) to get e.
(require srfi/1)
(define ops '(+ - * /))
(defun remote-shell-fav-hosts-get ()
"My hook to the remote-shell processes in order to connect to
my OpenStack controller, and create a hashtable of host names as
the keys, and IP addresses as the values."
(interactive)
;; Run nova list command remotely on this host system, and put the
;; results in a temp buffer:
(let* ((undercloud-controller "10.98.1.145")
(default-directory (format "/ssh:%s:" undercloud-controller))
@pathikrit
pathikrit / NQueen.scala
Last active January 19, 2023 21:30
O(n!) solution to the n-Queen puzzle (https://en.wikipedia.org/wiki/Eight_queens_puzzle)
/**
* Solves the n-Queen puzzle in O(n!)
* Let p[r] be the column of the queen on the rth row (must be exactly 1 queen per row)
* There also must be exactly 1 queen per column and hence p must be a permuation of (0 until n)
* There must be n distinct (col + diag) and n distinct (col - diag) for each queen (else bishop attacks)
* @return returns a Iterator of solutions
* Each solution is an array p of length n such that p[i] is the column of the queen on the ith row
*/
def nQueens(n: Int): Iterator[Seq[Int]] =
(0 until n)
@floriandejonckheere
floriandejonckheere / 40_iso.cfg
Created September 29, 2015 07:50
GRUB entry for booting Arch Linux ISO
# This entry boots an Antergos (Arch) Linux ISO straight from disk.
# LVM is not supported because the lvm module is not loaded in Antergos initrd
menuentry "Antergos Minimal ISO 2015-09-13" {
insmod part_gpt
insmod lvm
insmod loopback
set root=(hd0,0)
set isofile=/antergos.iso
search --no-floppy --file ${isofile} --set
@CAFxX
CAFxX / persistent_pipes_linux.md
Last active January 4, 2024 04:32
Persistent pipes/circular buffers for Linux

📂 Persistent "pipes" in Linux

In a project I'm working on I ran into the requirement of having some sort of persistent FIFO buffer or pipe in Linux, i.e. something file-like that could accept writes from a process and persist it to disk until a second process reads (and acknowledges) it. The persistence should be both across process restarts as well as OS restarts.

AFAICT unfortunately in the Linux world such a primitive does not exist (named pipes/FIFOs do not persist

@mindplay-dk
mindplay-dk / session-life-cycle.md
Last active March 28, 2024 19:52
Complete overview of the PHP SessionHandler life-cycle

This page provides a full overview of PHP's SessionHandler life-cycle - this was generated by a set of test-scripts, in order to provide an exact overview of when and what you can expect will be called in your custom SessionHandler implementation.

Each example is a separate script being run by a client with cookies enabled.

To the left, you can see the function being called in your script, and to the right, you can see the resulting calls being made to a custom session-handler registed using session_set_save_handler().

@Pysis868
Pysis868 / grub.cfg
Last active February 25, 2024 06:41
My own configuration file for GRUB2 to boot various live distributions of Linux-based operating systems, along with some system tools. I tried to include a lot of sample configuration entries, even if I don't currently use them, so it may help others. Exceedingly long blog post: http://tehfishyblog.logdown.com/chips/306146-a-homemade-ultimate-bo…
# Config for GNU GRand Unified Bootloader (GRUB) (2)
# /boot/grub2/grub.cfg
# or
# /boot/grub/grub.cfg
# Mostly only 'legacy' CSM/BIOS boot methods currently.
# Unable to boot loop entries with Secure Boot
# Notes:
# Description:
# This grub.cfg file was created by Lance http://www.pendrivelinux.com
import numpy as np
# The Fibonacii matrix
M = np.array([[0, 1], [1, 1]], dtype=np.float32)
# Compute the eigendecomposition of the matrix
w, v = np.linalg.eig(M)
inv_v = np.linalg.inv(v)
base_case = np.array([0, 1]).T # base case as a column vector