Skip to content

Instantly share code, notes, and snippets.

View antoinerg's full-sized avatar

Antoine Roy-Gobeil antoinerg

View GitHub Profile
@antoinerg
antoinerg / default.nix
Created July 15, 2021 18:18
nix-build a Docker image
{ pkgs ? import <nixpkgs> { system = "x86_64-linux"; } }:
pkgs.dockerTools.buildImage {
name = "hello-docker";
config = {
Cmd = [ "${pkgs.hello}/bin/hello" ];
};
}
@antoinerg
antoinerg / app.py
Last active July 20, 2020 20:14
serve Dash app as a subdirectory
# -*- coding: utf-8 -*-
# Run this app with `DASH_URL_BASE_PATHNAME=/MY_PREFIX/ python app.py` and
# visit http://127.0.0.1:8050/MY_PREFIX/ in your web browser.
import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.express as px
import pandas as pd
@antoinerg
antoinerg / default.nix
Last active November 6, 2020 04:17
convert markdown string into html file
with import <nixpkgs> {};
{ string ? "# hello"}:
let
input = writeTextFile {
name = "index.md";
text = string;
};
in
stdenv.mkDerivation {
@antoinerg
antoinerg / index.html
Created April 23, 2019 16:34
Sankey-order
<head>
<!-- Plotly.js -->
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
</head>
<body>
<div id="myDiv"><!-- Plotly chart will be drawn inside this DIV --></div>
<script>
<!-- JAVASCRIPT CODE GOES HERE -->
</script>
@antoinerg
antoinerg / benchmark.sh
Last active August 29, 2015 14:25
Docker run overhead
#!/bin/bash
N=20
average_time () {
i=1
while [ "$i" -le $N ];
do eval $1
i=$(($i+1))
done 2>&1 | grep ^real | sed -e s/.*m// | awk '{sum +=$1} END {print sum / NR "s"}';
}
@antoinerg
antoinerg / xmlread_xinclude.m
Last active December 12, 2015 00:38
Matlab function to parse XInclude in XML files
function xdoc = xmlread_xinclude(filename)
% Parse XML expanding XInclude tags
parserFactory = javaMethod('newInstance',...
'javax.xml.parsers.DocumentBuilderFactory');
javaMethod('setXIncludeAware',parserFactory,true);
javaMethod('setNamespaceAware',parserFactory,true);
p = javaMethod('newDocumentBuilder',parserFactory);
xdoc=xmlread(filename,p);