Skip to content

Instantly share code, notes, and snippets.

View vidartf's full-sized avatar

Vidar Tonaas Fauske vidartf

View GitHub Profile

Keybase proof

I hereby claim:

  • I am vidartf on github.
  • I am vidartf (https://keybase.io/vidartf) on keybase.
  • I have a public key ASCSHa6RtsmQm2Klv8Z4MrxnhpPX-vgXVI8R03fa-72_hwo

To claim this, I am signing this object:

@vidartf
vidartf / listen.js
Created October 23, 2018 10:58
Eventful jupyter widgets model
class EventfulModel extends Widgetmodel {
// ...
setupListeners() {
// The names of the attributes that are widget references:
const referencePropNames = ['foo', 'bar'];
// The names of the attributes that are collections of widget references:
const nestedPropNames = ['baz', 'alice'];
@vidartf
vidartf / wcag-color-contrast.ts
Last active January 10, 2018 14:19
WCAG color contrast
// Copyright Simula Research Laboratory 2018
// Licenced under BSD-3
// This follows https://www.w3.org/TR/WCAG20-TECHS/G17.html
function transValue(value: number) {
if value <= 0.03928{
return value / 12.92;
} else {
return Math.pow((RsRGB + 0.055) / 1.055, 2.4);
@vidartf
vidartf / reg_win_fileext.py
Last active July 28, 2017 09:27
Released under CC0 1.0
import os
def register_file_ext(filetypes, docformat_name, command, icon_path):
"""
Parameters:
-----------
filetypes: sequence of strings
Sequence of string of file extensions with a leading dot (e.g. '.txt')
docformat_name: string
from nbdime.patching import patch
from nbdime.diff_format import DiffOp
def iterate_cells_diffed(notebook, diff):
"""Generates tuples of (base, remote) cells from a given notebook and diff.
Yields tuples in the format: (base_cell, remote_cell)
Added cells will be (None, added_cell),
removed cells (removed_cell, None),
unchanged cells (base_cell, base_cell) (check equality with `is` operator)
@vidartf
vidartf / async-kernel.py
Created March 24, 2017 09:05
Ipython kernel with asyncio loop
from tornado.ioloop import IOLoop
from tornado.platform.asyncio import AsyncIOMainLoop
import asyncio
import zmq.asyncio
import zmq.eventloop
import ipykernel.kernelapp
p = asyncio.get_event_loop_policy()