Skip to content

Instantly share code, notes, and snippets.

View hadrianw's full-sized avatar

Hadrian Węgrzynowski hadrianw

View GitHub Profile

Keybase proof

I hereby claim:

  • I am hadrianw on github.
  • I am hawski (https://keybase.io/hawski) on keybase.
  • I have a public key ASB7SqEkozW7v4jD75NZ4Mzrfz_OAY2jwl2v0SQkcI47TQo

To claim this, I am signing this object:

@hadrianw
hadrianw / index.c
Last active May 31, 2018 21:59
Dumb benchmark for VPS performance measurment.
#include <ftw.h>
#include <stdio.h>
#include <sqlite3.h>
#define INSERT_QUERY "INSERT INTO index VALUES (?, ?)",
static sqlite3 *db;
static sqlite3_stmt *insert_stmt;
static int step(const char *path, const struct stat *sb, int flag, struct FTW *ftwbuf)
@hadrianw
hadrianw / resize-allow.js
Created April 12, 2017 14:59
Bookrmarklet to add or modify meta viewport to allow resizing on mobile.
var d=document;
var q=d.querySelector.bind(d);
var c='width=device-width,initial-scale=1';
var v=q('meta[name=viewport]');
if(v){
v.content=c
}else{
v=d.createElement('meta');
v.name='viewport';
v.content=c;
@hadrianw
hadrianw / shebang.c
Last active November 13, 2022 21:30
Make a C file executable with those few lines.
#if 0
set -e; [ "$0" -nt "$0.bin" ] &&
gcc -Wall -Wextra -pedantic -std=c99 "$0" -o "$0.bin"
exec "$0.bin" "$@"
#endif
#include <stdio.h>
int
main(int argc, char *argv[]) {
@hadrianw
hadrianw / Makefile
Created March 13, 2017 14:11
Seven line Makefile for a directory full of single file basic programs.
all:
make $$(for i in *.c; do echo $${i%.c}; done)
.c: Makefile
gcc -std=c99 -pedantic -Wall -Wextra $< -o $@
.PHONY: all
@hadrianw
hadrianw / Makefile
Created March 13, 2017 14:06
Two line Makefile for a directory full of single file basic programs. Usage: make binary-name
.c: Makefile
gcc -std=c99 -pedantic -Wall -Wextra $< -o $@
@hadrianw
hadrianw / prace.c
Last active January 24, 2016 01:06
Process Race - wait for a child process to finish, kill the rest.
/*
Compile with:
$ gcc prace.c -o prace -std=c99 -pedantic -Wall -Wextra
Example usage in shell script:
$ ((sleep 4; echo foo)& (sleep 2; echo bar)& exec ./prace)
bar
$
*/