Skip to content

Instantly share code, notes, and snippets.

René Hansen rhardih

Block or report user

Report or block rhardih

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
@rhardih
rhardih / out.sh
Created Nov 22, 2017
http-server vs. http.listenAndServe scale
View out.sh
# http-server
rene $ for i in 16 128; do ab -c $i -n $i http://127.0.0.1:8080/ | grep "Time per"; done
Time per request: 20.492 [ms] (mean)
Time per request: 1.281 [ms] (mean, across all concurrent requests)
Time per request: 138.750 [ms] (mean)
Time per request: 1.084 [ms] (mean, across all concurrent requests)
# serve
rene $ for i in 16 128; do ab -c $i -n $i http://127.0.0.1:8080/ | grep "Time per"; done
Time per request: 3.465 [ms] (mean)
@rhardih
rhardih / call.sh
Last active Oct 25, 2017
valgrind callgrind Unrecognised instruction on macOS 10.12.6
View call.sh
valgrind --tool=callgrind ./oclinf
@rhardih
rhardih / Makefile
Created Sep 8, 2017
OpenCV cv::ocl::attachContext problem
View Makefile
INC=-I/Users/rene/Code/OpenCL-Headers/opencl12
PKG=`pkg-config --cflags --libs opencv`
LD=`pkg-config --libs-only-L opencv | cut -c 3-`
.PHONY: default a.out.lldb
default: build
LD_LIBRARY_PATH=$(LD) ./a.out
lldb: build a.out.lldb
LD_LIBRARY_PATH=$(LD) lldb --source a.out.lldb
@rhardih
rhardih / out.sh
Created Nov 22, 2016
Leptonica build fails to find include of custom compiled version of libjpeg
View out.sh
rene $ ls -la
total 0
drwxr-xr-x 2 rene staff 68 Nov 22 15:22 .
drwxr-xr-x 26 rene staff 884 Nov 22 14:15 ..
[~/Code/leptonica/build] (master)
rene $ tree ../dependencies/install/
../dependencies/install/
├── bin
│   ├── cjpeg
│   ├── djpeg
@rhardih
rhardih / rf.sh
Created Nov 20, 2016
List a random file from the current directory
View rf.sh
ls | head -$(($RANDOM % `ls | wc -l` + 1)) | tail -1
@rhardih
rhardih / md5c.sh
Created Nov 2, 2016
Bash utility shorthand to validate md5 checksums on files
View md5c.sh
#!/usr/bin/env bash
# md5c
#
# Perform md5 checksum validation of a file against
# a specified md5 hash.
#
# usage: md5c filename hash
function md5c {
filename="$1"
@rhardih
rhardih / when.js
Created Apr 18, 2016
Simple handler class providing callbacks when dom objects scroll into view
View when.js
var WhenHandler = function(id) {
this.elm = document.querySelector("#" + id);
this.scrolled_into_view = false;
this.scroll_callback;
this.doc = document.documentElement;
this.doc_bounds = this.doc.getBoundingClientRect();
this.elm_bounds = this.elm.getBoundingClientRect();
}
@rhardih
rhardih / pointer_fun.c
Created Oct 19, 2015
Simple example of manipulating contents of a pointer from within a function call.
View pointer_fun.c
#include <stdio.h>
#include <stdlib.h>
int pointer_pointer_function(int **pp)
{
printf("EQUAL WAYS OF ADDRESSING:\n");
printf("*(*pp + 0): %d\n", (int) *(*pp + 0));
printf("*(*pp + 1): %d\n", (int) *(*pp + 1));
printf("*(*pp + 2): %d\n", (int) *(*pp + 2));
@rhardih
rhardih / convert.sh
Created Aug 26, 2015
Recursively find and convert .epub to .mobi using calibres ebook-convert (in parallel)
View convert.sh
find . -name "*.epub" -exec sh -c 'ebook-convert "{}" "$(dirname "{}")/$(basename -s .epub "{}").mobi" &' \;
@rhardih
rhardih / uniquify.sh
Created Jun 18, 2015
Remove duplicates from a list of arguments in bash
View uniquify.sh
#!/usr/bin/env bash
function uniquify {
echo "$@" | tr ' ' '\n' | sort -u | tr '\n' ' '
}
You can’t perform that action at this time.