Skip to content

Instantly share code, notes, and snippets.

Avatar

Eirik Brandtzæg eirikb

View GitHub Profile
View fast-domdom.tsx
import domdom from "@eirikb/domdom";
import {
FASTDesignSystemProvider,
FASTButton,
FASTAccordion
} from "@microsoft/fast-components";
const { React, init, on, set, get } = domdom();
FASTDesignSystemProvider;
@eirikb
eirikb / discord-remove-sidepanels.js
Created Mar 19, 2020
Remove panels from discord
View discord-remove-sidepanels.js
document.querySelector('*[class^=membersWrap]').style.display = 'none'
document.querySelector('*[class^=sidebar]').style.display = 'none'
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 msal-outlook-native-hack.js
const isOutlookNative = Office.context.mailbox && Office.context.mailbox.diagnostics.hostName === 'Outlook';
if (isOutlookNative) {
msal.openPopup = () => {
const dummy = {
close() {
},
location: {
assign(url) {
Office.context.ui.displayDialogAsync(url, { width: 25 }, res => {
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
@eirikb
eirikb / app.js
Last active Nov 15, 2019
MSAL in Outlook Add-In
View app.js
import "core-js/stable";
import "regenerator-runtime/runtime";
import 'whatwg-fetch';
import { UserAgentApplication } from 'msal';
const clientId = '<PUT YOUR CLIENT ID HERE>';
const scopes = ['User.Read'];
const msal = new UserAgentApplication({ auth: { clientId } });
const p = document.querySelector('p');
View DI.kt
package gutsu
import no.eirikb.gutsu.Gutsu
interface PumpService {
fun startPump()
}
class DataDesk {
fun sendMessage(text: String) {
You can’t perform that action at this time.