Skip to content

Instantly share code, notes, and snippets.

Avatar

Eirik Brandtzæg eirikb

View GitHub Profile
View test.js
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 }]);
View run-durable-functions-async-without-emulator.js
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 Jan 10, 2020
DOM normailzation of table rows - creates a matrix with duplicate cells based on rowspan colspan
View normalize-table.js
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 Jan 7, 2020
Matrikkel: Oppslag nye kommunenummer (knr) og gårdsnummer (gnr) fra 2019 mot nye i 2020
View 2019-2020-knr-gnr.js
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 Jan 3, 2020
2019 2020 kommuenummer postnummer
View 2019-2020-kommuenummer-postnummer.md
@Francesco149
Francesco149 / docker-cross-device-link.md
Last active Sep 28, 2020
docker error creating new backup file '/var/lib/dpkg/status-old': Invalid cross-device link
View docker-cross-device-link.md
@eirikb
eirikb / 0-PXE-VDI-LTSP.md
Last active May 18, 2018
Host VDI / VMDK (VirtualBox images) directly over PXE (Network boot).
View 0-PXE-VDI-LTSP.md

PXE Boot VDI/VMDK over network

This is an example script of how to host VDI / VMDK (VirtualBox images) directly over PXE (Network boot).  
Example relies on LTSP.  

Client

Can be any distro, but requires ltsp-client-core, example with Debian:

sudo apt-get -y install ltsp-client-core
@eirikb
eirikb / .sassrc.js
Created Mar 15, 2018
Demo of parcel + scss
View .sassrc.js
const path = require('path');
const cwd = process.cwd();
module.exports = {
"includePaths": [
path.resolve(cwd, 'node_modules'),
path.resolve(cwd, 'src')
]
};
@eirikb
eirikb / Dockerfile
Created Aug 3, 2017
Arch Linux AUR in Docker
View Dockerfile
FROM base/archlinux
RUN pacman -Syu
RUN pacman -S --noconfirm git base-devel
WORKDIR /build
RUN useradd -d /build build-user
RUN echo "build-user ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
RUN chown -R build-user /build
@eirikb
eirikb / load-vue-components-from-folder.js
Created May 24, 2017
Load all Vue components from a given folder, no need for an "index.js"-file
View load-vue-components-from-folder.js
const req = require.context('./components/', true, /\.(js|vue)$/i);
req.keys().map(key => {
const name = key.match(/\w+/)[0];
return Vue.component(name, req(key))
});
You can’t perform that action at this time.