Skip to content

Instantly share code, notes, and snippets.

/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*/
#include <arpa/inet.h>
#include <linux/if_packet.h>
#include <linux/ip.h>
@javiermon
javiermon / etags-c-here.sh
Last active December 17, 2015 04:49
create emacs TAGS file for a C codebase
#!/bin/bash
# etags from emacs:
find . -name "*.[chCH]" -print | etags -
# exuberant ctags
# ctags -Re
# cscope
# cscope-indexer -r
@javiermon
javiermon / chroot-in.sh
Last active December 17, 2015 07:08
Script with gidelines for a 32bit chroot inside a amd64 os.
#!/bin/bash
# http://www.gentoo.org/proj/en/base/amd64/howtos/chroot.xml
USER=jmonteagudo
CHROOT=/chroot/precise-32
# mount the usual suspects
mount -o bind /tmp $CHROOT/tmp/
mount -t proc proc $CHROOT/proc/
mount -t sysfs sys $CHROOT/sys/
mount -o bind /dev $CHROOT/dev/
@javiermon
javiermon / list.h
Last active December 17, 2015 09:38
Usable code-drop copy of linux/list.h
#ifndef __LIST_H
#define __LIST_H
/* This file is from Linux Kernel (include/linux/list.h)
* and modified by simply removing hardware prefetching of list items.
* Here by copyright, credits attributed to wherever they belong.
* Kulesh Shanmugasundaram (kulesh [squiggly] isis.poly.edu)
*/
/*
@javiermon
javiermon / create-tunnel.sh
Last active December 17, 2015 19:09
tunnel ssh for remote connections (for all connections: 0.0.0.0)
#!/bin/bash
if [ "$#" -ne 1 ]
then
echo "SERVER:RPORT:LPORT argument required"
exit 1
fi
# parse parameters separated with ':' into bash array
PARAMS=(${1//:/ })
SERVER="${PARAMS[0]}"
@javiermon
javiermon / percentile_cont.js
Created June 3, 2013 18:15
percentile_cont in js
// http://stackoverflow.com/questions/14300004/postgresql-equivalent-of-oracles-percentile-cont-function
var percentile_cont = function (data, percentile) {
var row = (percentile*(data.length -1));
var crn = Math.ceil(row);
var frn = Math.floor(row);
var result = 0.0;
data.sort(function(a,b){return a-b});
if ((crn == frn) && (frn == row)) {
#!/usr/bin/perl
# Simple perl script to list files with a given CVS tag
# Created 2002/09/10 ec
# $Id: lstag,v 1.1 2002/09/26 10:02:53 ec Exp $
use strict;
$::VERSION = "1.0";
$::cvs_ID = '$Id: lstag,v 1.1 2002/09/26 10:02:53 ec Exp $'; #'
@javiermon
javiermon / functions.js
Last active December 18, 2015 11:18 — forked from RedBeard0531/functions.js
Min, Max, Sum, Count, Avg, and Std deviation using MongoDB MapReduce
// derived from http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Parallel_algorithm
function map() {
emit(1, // Or put a GROUP BY key here
{sum: this.value, // the field you want stats for
min: this.value,
max: this.value,
count:1,
diff: 0, // M2,n: sum((val-mean)^2)
});

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@javiermon
javiermon / LICENSE
Last active May 5, 2024 05:15
get default gateway
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.