Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
#include <string.h>
int main(int argc, char const *argv[])
{
int i, j, mod;
char tmp[50] = "";
char result[50] = "";
for(i = 1; i < 817; i++) {
@rhardih
rhardih / crontab
Last active August 29, 2015 14:23
Cleanup stuff in ~/Downloads/
0 12 * * * find ~/Downloads/ -mtime +7 -maxdepth 1 -exec rm -rf {} \;
@rhardih
rhardih / uniquify.sh
Created June 18, 2015 12:39
Remove duplicates from a list of arguments in bash
#!/usr/bin/env bash
function uniquify {
echo "$@" | tr ' ' '\n' | sort -u | tr '\n' ' '
}
@rhardih
rhardih / pointer_fun.c
Created October 19, 2015 23:28
Simple example of manipulating contents of a pointer from within a function call.
#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 / when.js
Created April 18, 2016 14:50
Simple handler class providing callbacks when dom objects scroll into view
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 / md5c.sh
Created November 2, 2016 11:42
Bash utility shorthand to validate md5 checksums on files
#!/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 / rf.sh
Created November 20, 2016 17:08
List a random file from the current directory
ls | head -$(($RANDOM % `ls | wc -l` + 1)) | tail -1
@rhardih
rhardih / out.sh
Created November 22, 2016 14:26
Leptonica build fails to find include of custom compiled version of libjpeg
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 / Makefile
Created September 8, 2017 11:10
OpenCV cv::ocl::attachContext problem
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 / call.sh
Last active October 25, 2017 11:32
valgrind callgrind Unrecognised instruction on macOS 10.12.6
valgrind --tool=callgrind ./oclinf