Skip to content

Instantly share code, notes, and snippets.

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@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)
});
/*
* 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>
/*
* 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 <stdio.h>
@javiermon
javiermon / bitutils.py
Created December 13, 2012 13:02 — forked from anonymous/bitutils.py
handy functions to work with bits
# (unset) mask = 0xff - (1 << offset) if (nibble == 'lower') else 0xff - (4 << (4 - offset)); operation = &
# (set) mask = 1 << offset if (nibble == 'lower') else 4 << (4 - offset); operation = |
#
# (read) result = (current_values & 0x0F) if (nibble == 'lower') else (current_values & 0xF0) >> 4
# (write) mask = (offset - 1) & 0xf0 if (nibble == 'lower') else 4 << (offset - 1) & 0x0f; operation = |
def getNibbles(int_type):
""" getNibbles() returns the byte nibbles for a given integer (upper, lower) """
return((int_type & 0xF0) >> 4, (int_type & 0x0F))
@javiermon
javiermon / prename.pl
Created October 23, 2012 15:43
`prename` script from Debian's 'perl' package
#!/usr/bin/perl -w
#
# This script was developed by Robin Barker (Robin.Barker@npl.co.uk),
# from Larry Wall's original script eg/rename from the perl source.
#
# This script is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
#
# Larry(?)'s RCS header:
# RCSfile: rename,v Revision: 4.1 Date: 92/08/07 17:20:30
@javiermon
javiermon / mongoserver.py
Created July 26, 2012 22:38 — forked from chergert/mongoserver.py
Just enough of a mongoserver to handle a mongo shell connecting.
#!/usr/bin/env python
"""
A sample Mongo server that handles enough of the commands to connect
with the mongo shell.
Requires: https://github.com/chergert/mongo-async-python-driver
"""
from collections import OrderedDict
@javiermon
javiermon / gDNS.py
Created March 14, 2012 10:46 — forked from waawal/gDNS.py
gevent/dnslib/redis based DNS server
# dns server using dnslib and gevent
# based on https://bitbucket.org/paulc/dnslib/src/80d85555aae4/src/server/gevent_server.py
# set the key as
# set IP:name ip_addr
# set TXT:name txtfield
# fallback on gevent's dns resolver
# gleicon 2011
import gevent