Skip to content

Instantly share code, notes, and snippets.

Do Updates

Install Scoop

In powershell

Set-ExecutionPolicy RemoteSigned -scope CurrentUser
Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')
#!/bin/bash
# Set EVENTS and INTERVAL as environment variables, else they will get these defaults
# % INTERVAL=5 EVENTS="cycles:u" sh perf_to_picked_df.sh
EVENTS=${EVENTS:-"cycles:u"}
INTERVAL=${INTERVAL:-300} #sec
PRINT_M=${PRINT_M:-no} # Set this to yes if you want to print the matrix
# This will write FILE.p where FILE will be a ISO8601 timestamp in the format
# YMDTHMS, e.g. 20160608T190048. Also note that you will need to run this as root, or use sudo.
@stelfer
stelfer / README.md
Created September 6, 2012 19:27
bind test
@stelfer
stelfer / cat5kutils.py
Created May 15, 2012 00:08
Find a MAC on a CatOS switch
#!/usr/bin/env python
"""
Finds a MAC on a switch/card/port of a CatOS switch
"""
# global settings
port = 161
retries = 5
timeout = 1
@stelfer
stelfer / mg.c
Created May 15, 2012 00:06
A Ghetto MGCP simulator
/*
* This simulates a MGCP gateway for testing purposes
*/
/* $Id$ */
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
@stelfer
stelfer / spin.c
Created May 15, 2012 00:04
A spinning wheel on your command line
#include <stdio.h>
int main() {
printf("Working [%c]", '|');
fflush(stdout);
for (i=0; i<10; ++i) {
sleep(1);
printf("%c%c%c]", 0x08, 0x08, ind[i%4]);
fflush(stdout);
}
}
@stelfer
stelfer / spoof_forward.c
Created May 15, 2012 00:03
Reads a udp packet on one addr:port and forwards to another addr:port with another src addr:port
/*
* This trivial little program listens on one port and forwards udp to
* another IP with a given source address. This was used to proxy
* snmp traps at some point.
*
* You absolutely have to ifconfig or ip add the spoofed alias. Yeah
* we could do it through netlink sockets, but ...
*/
#include <sys/socket.h>
#include <netinet/in.h>
@stelfer
stelfer / backup.sh
Created May 14, 2012 23:56
simple backup script for LVMs
#!/bin/bash
#set -ex
# cleanup function, only invoked after exit after successful lv
# allocation
cleanup ()
{
echo -n "BACKUP REMOVE:"
lvremove -f $SNAPSHOT_DEV
@stelfer
stelfer / greplin.c
Created October 9, 2010 18:24
Answers for greplin coding challenge
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <math.h>
#define DIM(x) sizeof(x)/sizeof(x[0])
#define IS_SET(x,bit) ((x & (1 << bit)) != 0)
static char level1_data[] = "FourscoreandsevenyearsagoourfaathersbroughtforthonthiscontainentanewnationconceivedinzLibertyanddedicatedtothepropositionthatallmenarecreatedequalNowweareengagedinagreahtcivilwartestingwhetherthatnaptionoranynartionsoconceivedandsodedicatedcanlongendureWeareqmetonagreatbattlefiemldoftzhatwarWehavecometodedicpateaportionofthatfieldasafinalrestingplaceforthosewhoheregavetheirlivesthatthatnationmightliveItisaltogetherfangandproperthatweshoulddothisButinalargersensewecannotdedicatewecannotconsecratewecannothallowthisgroundThebravelmenlivinganddeadwhostruggledherehaveconsecrateditfaraboveourpoorponwertoaddordetractTgheworldadswfilllittlenotlenorlongrememberwhatwesayherebutitcanneverforgetwhattheydidhereItisforusthelivingrathertobededicatedheretotheulnfinishedworkwhichtheywhofoughtherehavethusfarsonoblyadva