Skip to content

Instantly share code, notes, and snippets.

View royvandam's full-sized avatar
🚀

Roy van Dam royvandam

🚀
View GitHub Profile
@royvandam
royvandam / CMakeLists.txt
Created July 2, 2012 14:11
Adds an uninstall target to the CMAKE generated Makefile.
##
# Add uninstall target
# Requirements: Copy the uninstall.cmake file to the appropriate CMAKE_MODULE_PATH.
#
add_custom_target(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_MODULE_PATH}/uninstall.cmake"
)
@royvandam
royvandam / jquery.anti-spam.js
Created November 9, 2013 15:42
Simple email addresses protection using jQuery
/**
* Easy to use, email protection using jQuery.
* Just the following to your HTML:
* <a href="#"><span class="email" user="me" domain="example" tld=".com"></span></a>
*/
$(document).ready(function() {
$('.email').html(function() {
var address = $(this).attr('user') + '@' + $(this).attr('domain') + $(this).attr('tld');
$(this).parent('a').attr('href', 'mailto:' + address);
@royvandam
royvandam / memscan
Created November 19, 2014 12:44
Small application for quickly searching the location of files or chunks of a file in a physical disk image.
#define _GNU_SOURCE
#include <string.h>
#include <fcntl.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
@royvandam
royvandam / milage.py
Last active November 30, 2015 15:40
Interpolate car milage to month boundaries for use with ERP systems.
#!/usr/bin/python
import sys
import re
import calendar
from datetime import date
from dateutil.relativedelta import relativedelta
date_format = '%Y/%m/%d'
@royvandam
royvandam / index.html
Created April 16, 2015 15:27
css3 skewed menu
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>skew menu</title>
</head>
<body>
<nav>
<ul>
@royvandam
royvandam / autossh
Last active November 17, 2015 12:58
AutoSSH
#!/bin/bash
# Default settings
hostname=server.example.com
port=22
keep_alive_interval=300
keep_alive_count_max=2
backoff=30
user=user
@royvandam
royvandam / randmac.sh
Last active August 29, 2015 14:26
Randomise your ethernet mac address for bypassing free wifi time limits.
#!/bin/bash
if=${1-en1}
function get_if_mac() {
local if=$1
ifconfig en1 | grep ether | sed -e 's/^[[:space:]]ether //'
}
mac=$(get_if_mac $if)
@royvandam
royvandam / server2server.py
Created October 1, 2016 12:55
Small python script that connects one or more TCP servers to each other.
#!/usr/bin/env python
import sys
import socket
import select
def usage(name):
print('Usage {} [hostname:port](2..n)'.format(name))
if (len(sys.argv) < 3):
@royvandam
royvandam / selector.py
Last active October 21, 2016 13:22
Some BeagleBone Black python code to poll a digital IO pin and send a UDP command to a video player
#!/usr/bin/env python2
import signal, time, threading, socket, sys
import Adafruit_BBIO.GPIO as GPIO
class Pir:
def __init__(self, pin, pud=GPIO.PUD_UP):
self.pin = pin
self.pud = pud
GPIO.setup(self.pin, GPIO.IN, pull_up_down=pud)
@royvandam
royvandam / svn_stash.sh
Created December 7, 2016 15:15
Hackish Git like SVN stash drop in shell function
svn() {
local svn_cmd='/usr/bin/env svn'
case $1 in
stash)
case $2 in
"")
if ! $svn_cmd status | grep -q '^M'; then
echo "No outstanding changes"
return
fi