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
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 }]);
@eirikb
eirikb / clicktest.md
Last active April 9, 2021 16:49
Automated click testing in bash

About

This is a bash script, as an example, on how to do click-testing GUI based on finding components based on how they look.

Dependencies

@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 / load-vue-components-from-folder.js
Created May 24, 2017 19:24
Load all Vue components from a given folder, no need for an "index.js"-file
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))
});
# 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 / 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"
@chinchang
chinchang / xmlToJson.js
Last active September 7, 2023 02:39
Function to convert XML to JSON
/**
* Changes XML to JSON
* Modified version from here: http://davidwalsh.name/convert-xml-json
* @param {string} xml XML DOM tree
*/
function xmlToJson(xml) {
// Create the return object
var obj = {};
if (xml.nodeType == 1) {
@eirikb
eirikb / .sassrc.js
Created March 15, 2018 09:24
Demo of parcel + scss
const path = require('path');
const cwd = process.cwd();
module.exports = {
"includePaths": [
path.resolve(cwd, 'node_modules'),
path.resolve(cwd, 'src')
]
};
@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
@hkoba
hkoba / sched-reboot.service
Last active November 6, 2023 16:07
systemd service and timer for scheduled reboot.
[Unit]
Description=Scheduled Reboot
[Service]
Type=simple
ExecStart=/usr/bin/systemctl --force reboot