Skip to content

Instantly share code, notes, and snippets.

View jdmichaud's full-sized avatar

jdmichaud

View GitHub Profile
@jdmichaud
jdmichaud / valgrind.sh
Last active December 22, 2017 10:18
Command to launch the static analyzer valgrind
valgrind --track-origins=yes --leak-check=full --show-leak-kinds=all ${prog} ${args}
@jdmichaud
jdmichaud / SimpleHTTPSServerWithCORS3.py
Last active October 3, 2021 09:49
Python based HTTP server with CORS
#!/usr/bin/env python3
import http.server
import socketserver
import ssl
IP = "0.0.0.0"
PORT = 4443
class CORSRequestHandler(http.server.SimpleHTTPRequestHandler):
def end_headers(self):
@jdmichaud
jdmichaud / README.md
Last active December 11, 2017 12:53 — forked from smoser/README.md
ubuntu-auto-install: install a ubuntu image with kvm

Purpose

For testing purposes, you will want to quickly spawn blank VMs with an ssh access to try out some stuff. This Gist from @smoser allows you to do just that. It:

  1. Provides a script to automatically download, install and configure an ubuntu base VM from your terminal using qemu/kvm
  2. Spawn blank and dispensable VMs from that base read-only VM

Quick start

Create the base VM

@jdmichaud
jdmichaud / observable-model.js
Last active December 22, 2017 10:57
Observable model
// npm install --save rxjs
// npm install --save-dev mocha
// # We need babel for decorator (ES7)
// npm install --save-dev babel-cli babel-preset-env
// cat > .babelrc << EOF
// {
// "presets": ["env"]
// }
// EOF
// node_modules/.bin/mocha observable-model.js
apt update
apt install -y curl xz-utils less
cd
curl -sOL https://nodejs.org/dist/v8.9.3/node-v8.9.3-linux-x64.tar.xz
tar xf node-v8.9.3-linux-x64.tar.xz
(export PATH=$PATH:/root/node-v8.9.3-linux-x64/bin; npm install -g n)
(export PATH=$PATH:/root/node-v8.9.3-linux-x64/bin; n latest)
npm update -g npm
rm -fr node-v8.9.3-linux-x64
npm install -g yo
// npm install --save lodash @types/lodash
import * as lodash from 'lodash';
class A {
public property: number;
}
class B {
public a: A;
}
@jdmichaud
jdmichaud / jq.md
Created January 16, 2018 08:14
Some jq examples
$ cat somefile
{
  "field": {
    "entry1": 12,
    "entry2": 42,
    "entry3": 8,
  }
}
@jdmichaud
jdmichaud / README.md
Last active April 4, 2018 08:54
Normalize vector with numpy

So you want to normalize a vector? Well numpy can do that for you with a little help.

First include numpy:

!INCLUDE normalized.py 1:1

Then call the norm function of the linealg module:

!INCLUDE normalized.py 4:6
@jdmichaud
jdmichaud / git-log.sh
Created March 27, 2018 11:34
git log goodness
git log --oneline --decorate --all --graph --stat
git log --oneline --decorate --all --graph --simplify-by-decoration
--oneline: resume each log to one line
--decorate: add branch/tag information
--all: include all branches
--graph: add a branching graph tree
--stat: list files for each commit
--simplify-by-decoration: show only signification commits (branches)