Skip to content

Instantly share code, notes, and snippets.

Mikael Sand msand

Block or report user

Report or block msand

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
@msand
msand / inliner.js
Created Mar 3, 2019
inline css to svg attributes
View inliner.js
const camelToKebab = camel => camel.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
/* Inline all rules from all CSS stylesheets as attributes
on all matching elements and remove class attribute */
const styles = Array.from(document.querySelectorAll("style"));
styles.forEach(styleSheet => {
Array.from(styleSheet.sheet.cssRules).forEach(rule => {
if (rule.style.display === "none") {
// Remove hidden elements
Array.from(document.querySelectorAll(rule.selectorText)).forEach(el => {
@msand
msand / .block
Last active Jan 27, 2019 — forked from pbeshai/.block
Animate thousands of points with Web Animations and D3
View .block
license: mit
height: 620
border: no
@msand
msand / .block
Last active Jan 27, 2019 — forked from hudsonb/.block
Animate thousands of points with svg and D3
View .block
license: mit
height: 620
border: no
@msand
msand / main.m
Created Dec 30, 2017
Test binary vs linear search on already sorted array, experiment suggests using linear up to < 16 elements
View main.m
//
// main.m
// TestSearch
//
// Created by Mikael Sand on 30/12/2017.
// Copyright © 2017 Mikael Sand. All rights reserved.
//
#import <Foundation/Foundation.h>
#include <mach/mach_time.h>
@msand
msand / transform.js
Created Nov 14, 2017
svg transform parser in peg.js
View transform.js
{
const deg2rad = Math.PI / 180;
/*
a c e
( b d f )
0 0 1
*/
function multiply_matrices(l, r) {
const [al, cl, el, bl, dl, fl] = l;
View rinkeby
0x542753E9629cA5E2d260A9e67940812A2ddD0190
@msand
msand / svg-css-inliner-color-hexer-gradient-defs-grouper-number-formatter.js
Last active Feb 19, 2019
Convert Illustrator SVG export into cross-platform CSS independent mode. CSS rule and style inlining, group gradients into a definitions tag, remove elements with display set to none, make colors hex. Works with react-native-web react-native-svg and svgs to give cross-platform web and native mobile rendering of any SVG produced in Illustrator.
View svg-css-inliner-color-hexer-gradient-defs-grouper-number-formatter.js
/*
Open console.
(Import https://raw.githubusercontent.com/MikeMcl/decimal.js/master/decimal.js first if you want/need number formatting)
Then copy & paste this + enter, to run this.
Copy console output to a NewFile.js or NewFile.jsx file.
prettier --write NewFile.js
*/
/* eslint no-console: ["error", { allow: ["log"] }] */
/* global document, Decimal*/
(() => {
View RBTree.fst
module RBTree
(* Some fixes to make it work in the browser editor @ https://www.fstar-lang.org/tutorial/
*)
(*
* Red black trees, and verification of Okasaki's insertion algorithm
* (https://wiki.rice.edu/confluence/download/attachments/2761212/Okasaki-Red-Black.pdf)
*)
(* CH: how does this compare to Andrew Appel's verified RB-trees
http://www.cs.princeton.edu/~appel/papers/redblack.pdf
@msand
msand / AVL.thy
Created Dec 6, 2016
AVL tree Isabelle/HOL
View AVL.thy
(* Mikael Sand msand@abo.fi *)
theory AVLproject
imports Main Int
begin
datatype 'a tree = Tip | Node "'a tree" 'a "'a tree"
primrec height :: "'a tree \<Rightarrow> nat" where
"height Tip = 0" |
"height (Node l v r) = 1 + max (height l) (height r)"
You can’t perform that action at this time.