Skip to content

Instantly share code, notes, and snippets.

Eirik Brandtzæg eirikb

Block or report user

Report or block eirikb

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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) {
View DI.kt
import no.eirikb.gutsu.Gutsu
class DataDesk {
fun sendMessage(text: String) {
println("${hashCode()}: Sending message: $text")
}
}
class PumpView(private val pumpService: PumpService) {
init {
View listener.rs
use async_std::io;
use async_std::net::{TcpListener, TcpStream};
use async_std::prelude::*;
use async_std::task;
use futures::{AsyncReadExt, future};
async fn in_to_out(incoming: TcpStream, outgoing: TcpStream) {
let (incoming_reader, incoming_writer) = &mut (&incoming, &incoming);
let (outgoing_reader, outgoing_writer) = &mut (&outgoing, &outgoing);
View msal-demo.js
<!DOCTYPE html>
<body>
<script src="https://secure.aadcdn.microsoftonline-p.com/lib/1.0.2/js/msal.min.js"></script>
<script>
const azureAdAppClientId = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx';
const sharePointUrl = 'https://xxxxxx.sharepoint.com';
const config = {
auth: {clientId: azureAdAppClientId},
cache: {cacheLocation: 'localStorage'}
View msal-domdom.html
<!DOCTYPE html>
<body>
<script src="https://unpkg.com/@eirikb/domdom@1.0.7"></script>
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<script src="https://secure.aadcdn.microsoftonline-p.com/lib/1.0.2/js/msal.min.js"></script>
<script type="text/babel">
const azureAdAppClientId = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx';
const sharePointUrl = 'https://xxxxxx.sharepoint.com';
You can’t perform that action at this time.