Skip to content

Instantly share code, notes, and snippets.

View ork's full-sized avatar
🥐

Benoît Taine ork

🥐
  • An tAontas Eorpach
View GitHub Profile
@ork
ork / section_anchor.js
Last active December 23, 2015 08:29
Add an anchor link reference to section headers.
[].forEach.call(document.querySelectorAll('h1,h2'), function(el) {
var section_anchor = document.createElement('a');
section_anchor.setAttribute('class', 'section_anchor');
section_anchor.setAttribute('title', 'Permalink');
section_anchor.setAttribute('href', '#' + el.id);
section_anchor.appendChild(document.createTextNode('¶'));
section_anchor.style.visibility = 'hidden';
el.appendChild(section_anchor);
el.addEventListener('mouseover', function() {
@ork
ork / parseoui.awk
Last active February 20, 2022 23:17
Parse IEEE OUI vendor list to JSON
#!/usr/bin/awk -f
# Parse IEEE OUI vendor list to JSON
# http://standards.ieee.org/develop/regauth/oui/oui.txt
# ---
# Usage:
# $ chmod +x parseoui.awk
# $ wget http://standards.ieee.org/develop/regauth/oui/oui.txt
# $ ./parseoui.awk oui.txt > oui.json
BEGIN {
@ork
ork / Makefile
Last active January 8, 2022 17:29
Generic C Makefile
EXEC = $(shell basename $$(pwd))
CC = gcc
CFLAGS = -std=gnu11 -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing
CFLAGS += $(shell pkg-config --cflags glib-2.0 gio-2.0)
LDFLAGS = $(shell pkg-config --libs glib-2.0 gio-2.0)
SRC = $(wildcard *.c)
OBJ = $(SRC:.c=.o)
@ork
ork / no_more_ifconfig
Last active January 8, 2022 17:29
Network interface stats
$ awk -F ' ' 'NR > 2 {printf("%-20s\n\tRX%15s packets\n\t%17s bytes\n\tTX%15s packets\n\t%17s bytes\n", $1, $3, $2, $11, $10);}' < /proc/net/dev
wlp2s0:
RX 13207 packets
2346094 bytes
TX 212 packets
44302 bytes
lo:
RX 131602 packets
13078892 bytes
TX 131602 packets
@ork
ork / Makefile
Created May 15, 2014 09:39
Generic LaTeX Makefile using latexmk and lualatex
MAINDOC = $(shell basename $$(pwd))
LTXARGS = -pdf -lualatex -use-make
.PHONY: $(MAINDOC).pdf all clean
all: $(MAINDOC).pdf
$(MAINDOC).pdf: $(MAINDOC).tex
latexmk $(LTXARGS) $(MAINDOC).tex
@ork
ork / Example.md
Created May 15, 2014 14:48
Print GameBoy VRAM tiles in your terminal

Source

00333300
03111130
31111213
31111113
31211113
31221113
@ork
ork / .Xresources
Created May 25, 2014 10:03
URxvt configuration file
! Window
URxvt.scrollBar: false
URxvt.borderLess: true
URxvt.internalBorder: 0
URxvt.externalBorder: 0
URxvt.iconFile: /usr/share/icons/Faenza/apps/16/terminal.png
! Fonts
URxvt.font: xft:Monospace:size=9
URxvt.depth: 32
@ork
ork / free_sms
Last active August 29, 2015 14:02
Send SMS using the Free Mobile gateway.
#!/usr/bin/env bash
## User config
FREE_USER=${FREE_USER:-'MY_LOGIN'}
FREE_PASS=${FREE_PASS:-'MY_API_KEY'}
## Go go go
FREE_URI='https://smsapi.free-mobile.fr/sendmsg'
@ork
ork / sdl2_context.c
Created June 10, 2015 09:46
SDL2 context example
#include <stdbool.h>
#include <SDL2/SDL.h>
#define PICTURE_SIZE_WIDTH 640
#define PICTURE_SIZE_HEIGHT 480
#define PICTURE_AT(x, y) (y * PICTURE_SIZE_WIDTH + x)
/*
* Declarations
*/
@ork
ork / fuzzy_search.c
Last active August 29, 2015 14:25
Fuzzy string search
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
static bool
_fuzzy_search(const char *needle, const char *haystack)
{
size_t hlen = strlen(haystack);
size_t nlen = strlen(needle);