Skip to content

Instantly share code, notes, and snippets.

@omeranson
omeranson / pydict2json.py
Created February 1, 2019 08:29
Utility to convert python values to json (Uses `eval`. Use only on trusted data!)
#!/bin/env python3
import json
import sys
def get_streams():
if len(sys.argv) == 1:
yield sys.stdin
return
#!/bin/awk -f
function red(s) {
return "\033[1;31m" s "\033[0m "
}
/idle_age=.,/ { $0 = red($0) }
{ print }
@omeranson
omeranson / init_git_repo.sh
Created August 17, 2017 11:40
Initialise a git repo for which push -f works out-of-the-box, and automatically resets to the updated commit.
#!/bin/bash
git init
git config receive.denyCurrentBranch ignore
touch .git/hooks/post-receive
chmod +x .git/hooks/post-receive
cat >> .git/hooks/post-receive << EOF
#!/bin/bash
@omeranson
omeranson / retry.sh
Created July 26, 2017 06:34
retry.sh: Retry a command until it succeeds
#!/bin/bash
# defaults
timeout=2s
function usage() {
echo "USAGE: $0 [-i interval] <command>"
echo " Retry running <command> every <interval> until it succeeds"
}
@omeranson
omeranson / timeout.cpp
Created July 4, 2017 19:02
A Timeout class in C++
#include <cstdio>
#include <setjmp.h>
#include <signal.h>
#include <unistd.h>
class Timeout;
static Timeout * global_timeout_instance = 0;
class Timeout {
public:
- hosts: all
tasks:
- name: Update apt
apt:
update_cache: yes
become: yes
become_user: root
tags:
- os_neutron-tox
- overlay-test
#!/usr/bin/perl
my $BRIDGE="br-int";
#Ping fe:16:3e:86:fc:28/10.0.0.10 -> fa:16:3e:cc:bd:da/10.0.0.9
#my $INPUT_FLOW='in_port=10,dl_src=fa:16:3e:86:fc:28,dl_dst=fa:16:3e:cc:bd:da,icmp,nw_src=10.0.0.10,nw_dst=10.0.0.9';
my $IN_PORT="10";
my $ETH_DST="fa:16:3e:86:fc:28";
my $IP_DST="10.0.0.10";
#my $ETH_DST="fa:16:3e:a6:5a:a5";
#my $IP_DST="10.0.0.1";