Skip to content

Instantly share code, notes, and snippets.

View eirikb's full-sized avatar

Eirik Brandtzæg eirikb

  • Softeria AS
  • Ålesund, Norway
View GitHub Profile
@eirikb
eirikb / qemu-archlinux-aarch64.sh
Created April 30, 2023 14:23
QEMU Arch Linux ARM64 aarch64
wget http://os.archlinuxarm.org/os/ArchLinuxARM-aarch64-latest.tar.gz
qemu-img create root.img 32G
mkfs.ext4 root.img
mkdir root
sudo mount root.img root
sudo bsdtar -xpf ArchLinuxARM-aarch64-latest.tar.gz -C root
sudo cp -r root/boot .
sudo umount root
qemu-system-aarch64 -M virt -cpu cortex-a72 -kernel boot/Image -hda root.img -append "root=/dev/vda rw"
# az login
# check: az resource list | grep <your azure function name>
# If not available you also need to change subscription
# az account set --subscritipon <sub id, find this in portal, or by az account list>
webAppName="<your azure functions name here>"
spId=$(az resource list -n $webAppName --query [*].identity.principalId --out tsv)
graphResourceId=$(az ad sp list --display-name "Microsoft Graph" --query [0].id --out tsv)
@eirikb
eirikb / insecureproxy.js
Last active October 25, 2021 18:41
Insecureproxy: Client -> [http] -> Insecureproxy -> [https] -> Proxy -> [https] -> Web
const http = require("http");
const https = require("https");
const fs = require("fs");
const auth = `Basic ${Buffer.from(
process.env.PROXY_USER + ":" + process.env.PROXY_PASS
).toString("base64")}`;
function proxy(id, url, method, headers, data, origRes, withCa) {
const parts = url.split("/").slice(2);
return new Promise((resolve, reject) => {
@eirikb
eirikb / qemu-arch-linux-raspi2.sh
Last active March 29, 2024 18:12
Arch Linux in QEMU for Raspberry Pi 2
#!/usr/bin/env bash
echo
echo "Arch Linux in QEMU with love from eirikb"
echo
set -x
TARGET=ArchLinuxARM-rpi-armv7-latest.tar.gz
wget "http://os.archlinuxarm.org/os/$TARGET"
const test = require('ava');
const when = require('./when');
const { sp } = require('@pnp/pnpjs');
test('when', t => {
const mySp = when(sp);
mySp.web.getList('web/Lists/A').items.filter(`Title eq 'yes'`).get.thenReturn([{ Id: 1 }]);
mySp.web.getList('web/Lists/A').items.filter(`Title eq 'no'`).get.thenReturn([{ Id: 2 }]);
mySp.web.getList('web/Lists/B').items.filter(`Title eq 'yes'`).get.thenReturn([{ Id: 3 }]);
const fs = require('fs');
const head = () => {
Object.assign(process.env, require('../local.settings').Values);
const orchestrators = {};
console.log.error = console.error;
const context = { log: console.log };
const setInput = input => context.bindings = { input: { input } };
const df = {
orchestrator(cb) {
@eirikb
eirikb / normalize-table.js
Last active January 10, 2020 20:16
DOM normailzation of table rows - creates a matrix with duplicate cells based on rowspan colspan
module.exports = table => {
const res = [];
table.querySelectorAll('tbody tr').forEach((row, y) =>
row.querySelectorAll('td').forEach((cell, x) => {
const rowspan = Number(cell.getAttribute('rowspan') || 1);
const colspan = Number(cell.getAttribute('colspan') || 1);
while (res[y] && res[y][x]) x++;
for (let yy = y; yy < y + rowspan; yy++) {
const resRow = res[yy] = res[yy] || [];
@eirikb
eirikb / 2019-2020-knr-gnr.js
Last active January 7, 2020 13:51
Matrikkel: Oppslag nye kommunenummer (knr) og gårdsnummer (gnr) fra 2019 mot nye i 2020
const data = require('./2019-2020-knr-gnr.json');
/**
* @typedef {Object} Matrikkel
* @property {string} knr - Kommunenummer
* @property {number} gnr - Gårdsnummer
*/
function sanitizeKnr(knr) {
return String(knr || '').padStart(4, '0');
@eirikb
eirikb / 2019-2020-kommuenummer-postnummer.md
Last active January 3, 2020 19:34
2019 2020 kommuenummer postnummer
@Francesco149
Francesco149 / docker-cross-device-link.md
Last active October 27, 2023 08:51
docker error creating new backup file '/var/lib/dpkg/status-old': Invalid cross-device link