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 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';
@eirikb
eirikb / store.js
Created Jan 6, 2019
Auto Vuex mutations
View store.js
import Vue from 'vue';
import Vuex from 'vuex';
Vue.use(Vuex);
function teenageAutoMutateTurtles(...props) {
return props.reduce((o, p) => (o[`set${p[0].toUpperCase()}${p.slice(1)}`] = (s, v) => s[p] = v) && o, {});
}
export default new Vuex.Store({
@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.