Skip to content

Instantly share code, notes, and snippets.

View khufkens's full-sized avatar

Koen Hufkens khufkens

View GitHub Profile
@jboner
jboner / latency.txt
Last active May 5, 2024 03:12
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@kylebgorman
kylebgorman / autoloess.R
Last active November 28, 2022 16:06
autoloess.R: set the "span" (smoothing) hyperparameter for a LOESS curve so as to minimize AIC_c (includes a cute demonstration)
# autoloess.R: compute loess metaparameters automatically
# Kyle Gorman <gormanky@ohsu.edu>
aicc.loess <- function(fit) {
# compute AIC_C for a LOESS fit, from:
#
# Hurvich, C.M., Simonoff, J.S., and Tsai, C. L. 1998. Smoothing
# parameter selection in nonparametric regression using an improved
# Akaike Information Criterion. Journal of the Royal Statistical
# Society B 60: 271–293.
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@dperelman
dperelman / blend.sh
Created March 8, 2015 10:40
Create simple slideshow video with blend effect between images.
#!/bin/sh
# Need at least an outfile and two images for this command to make sense.
if [ $# -lt 3 ]
then
echo USAGE: "$0" OUTFILE IMAGES...
echo Create simple slideshow video with blend effect between images.
echo
echo OUTFILE is video file to create, .mkv extension is recommended.
echo IMAGES is a sequence of images for the slideshow.
@fmder
fmder / elastic_transform.py
Last active August 22, 2021 14:54
Elastic transformation of an image in Python
import numpy
from scipy.ndimage.interpolation import map_coordinates
from scipy.ndimage.filters import gaussian_filter
def elastic_transform(image, alpha, sigma, random_state=None):
"""Elastic deformation of images as described in [Simard2003]_.
.. [Simard2003] Simard, Steinkraus and Platt, "Best Practices for
Convolutional Neural Networks applied to Visual Document Analysis", in
@andrie
andrie / doSNOW.R
Created October 21, 2015 10:08
Progress bars with foreach and doSNOW
library(doSNOW)
library(tcltk)
cl <- makeSOCKcluster(2)
registerDoSNOW(cl)
pb <- txtProgressBar(max=100, style=3)
progress <- function(n) setTxtProgressBar(pb, n)
opts <- list(progress=progress)
r <- foreach(i=1:100, .options.snow=opts) %dopar% {
@Rambou
Rambou / gist:c6769caee19b0b9915d8342b86c3ef72
Last active June 13, 2022 09:39
Installing Nvidia propreatary drivers in Linux with UEFI enabled
If, like me, your are booting with UEFI (because having a triple boot ubuntu-windows-mac or because UEFI is the most modern type of bootloader and successor of EFI :p), you have to sign the proprietary modules each time they are recompiled (or upgrade kernel version) so that they are allowed to be loaded in the kernel.
1) Step one, create a self-signed certificate to sign nvidia driver:
sudo openssl req -new -x509 -newkey rsa:2048 -keyout UEFI.key -outform DER -out UEFI.der -nodes -days 36500 -subj "/CN=rambou_nvidia/"
2) step two load and store certificate in a supplementary key database MOC
sudo mokutil --import UEFI.der
3) step three reboot your system
At this step after reboot you will be prompted to select your certificate to import in in key database. If you have inserted a password at certificate creation you'll be prompted to insert it. If you are not prompted, you may have to enter the BIOS by using function keys at boot time.
@J-Cleeland
J-Cleeland / albatross_breeding_cycle.Rmd
Last active June 18, 2018 21:10
Circular timeline of Southern Ocean albatross breeding cycles using ggplot. Note: BBA, black-browed albatross; LMA, light-mantled albatross; GHA, grey-headed albatross; WA, Wandering albatross.
---
title: "albatross_breeding_cycle"
author: "Jaimie Cleeland jaimie.cleeland@utas.edu.au"
date: "12/12/2016"
output: html_document
---
Load libraries
```{r}
library(dplyr)
@fbreitwieser
fbreitwieser / acc.R
Created April 27, 2018 14:45
common legend with cowplot
a = read.delim("~/Accuracy_as_a_function_of_sketch_size_and_set_size.txt")
head(a)
a$rel_error = sqrt(a$Mean.squared.error) / a$Exact.size
a$p = factor(a$Sketch.size..log2.)
library(cowplot)
library(ggplot2)
plot1 = ggplot(a, aes(x=Exact.size, sqrt(Mean.squared.error) / Exact.size,
# This example demonstrates running furrr code distributed on 2 AWS instances ("nodes").
# The instances have already been created.
library(future)
library(furrr)
# Two t2.micro AWS instances
# Created from http://www.louisaslett.com/RStudio_AMI/
public_ip <- c("34.205.155.182", "34.201.26.217")