Skip to content

Instantly share code, notes, and snippets.

@cl4u2
cl4u2 / del_first_lines.lua
Created September 11, 2014 14:55
Delete first n lines of a string
function del_first_lines(astring, n)
-- parameters: string and number of initial lines to be deleted
local result = ""
local deleted = n
local newfirst = true
for line in astring:gmatch("[^\r\n]+") do
if deleted > 0 then
deleted = deleted - 1
else
if newfirst then
@cl4u2
cl4u2 / drawtopology.sh
Last active August 16, 2017 18:19
OLSR topology draw
FONTNAME="Courier"
FONTSIZE=12
SIZE="64,64"
BGCOLOR="black"
OUTNAME="/media/topologies/latest"
FILENAME="${OUTNAME}.dot"
/bin/nc localhost 2004 > ${FILENAME}.tmp
#if the topologies are repeated take only the last one
@cl4u2
cl4u2 / route_dump.c
Created March 20, 2013 12:46
Linux route monitoring example
/*
iflist.c : retrieve network interface information thru netlink sockets
(c) Jean Lorchat @ Internet Initiative Japan - Innovation Institute
v1.0 : initial version - Feb 19th 2010
This file was obtained at the following address :
http://www.iijlab.net/~jean/iflist.c