Skip to content

Instantly share code, notes, and snippets.

@alan-mushi
alan-mushi / ripe_test.ex
Last active July 15, 2020 22:55
Ripe inetnum elixir parsing (OOM-killer)
# Add flow as a mix dep
# Killed by the OOM-killer
defmodule RipeTest do
use ExUnit.Case
doctest Ripe
# From https://ftp.ripe.net/ripe/dbase/split/
@filename "./assets/ripe.db.inetnum.gz"
@outfile 'inetnum.dets'
@alan-mushi
alan-mushi / benchmark.log
Last active February 12, 2016 12:51
Simple benchmark on functions using loggers and decorators.
__main__.function_to_benchmark|0:00:00.000172
__main__.function_to_benchmark|0:00:01.001560
__main__.function_to_benchmark|0:00:02.001992
@alan-mushi
alan-mushi / thunar-openssl-encrypt.sh
Created February 9, 2016 11:49
Simple Encryption/Decryption in Thunar's contextual menu
#!/bin/sh
usage() {
echo "$0 -f <filename>"
echo
echo " required:"
echo " -f input filename"
echo
}
@alan-mushi
alan-mushi / easy-graphviz.py
Created December 26, 2015 12:23
Easy graphviz for a simple graph in Python 3
# Install graphviz using pip3 (on archlinux):
# $ sudo pip3 install graphviz
import graphviz as gv
g1 = gv.Graph(format="svg") # "svg" or "dot"
g1.node('A')
g1.node('B')
g1.node('C')
g1.edge('A', 'C')
g1.edge('B', 'C')
@alan-mushi
alan-mushi / markdown_with_bootstrap_css.sh
Last active December 19, 2015 17:17
Generate a HTML page from markdown files with Bootstrap CSS
#!/bin/bash
check_args=${@:?You forgot the markdown file(s) as arg}
cat << EOF
<html>
<head>
<title></title>
<!-- Bootstrap css themes -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
@alan-mushi
alan-mushi / scan.py
Created December 2, 2015 10:40
SRI TP scapy TCP connect dumb scanner
from scapy.all import *
ip_dst = "104.16.34.249"
for i in range(1, 65536):
ans,uns = sr(IP(dst=ip_dst) / TCP(dport=i, flags="S"), timeout=1, retry=-2, verbose=False)
try:
if ans[0][1].getlayer(TCP).flags & 0x12 == 0x12:
print str(i) + " is open"
@alan-mushi
alan-mushi / pulseaudio_toggle_mute.sh
Created November 8, 2015 14:11
This simple helper script toggle the mute attribute for a program in pulseaudio.
#!/bin/bash
# This simple helper script toggle the mute attribute for a program in pulseaudio.
PROG="Chromium"
all=$(pacmd list-sink-inputs | egrep -B 15 "client: [0-9]+ <${PROG}>" | sed -n '1p;8p')
index=${all:11:2} # get the index
muted=${all:22:3} # get 'yes' or 'no'
#include <click/config.h>
#include <click/args.hh>
#include "DummyAnswer.hh"
#include "DummyProto.hh"
CLICK_DECLS
DummyAnswer::DummyAnswer() { };
DummyAnswer::~DummyAnswer() { };
@alan-mushi
alan-mushi / hello.click
Last active November 21, 2016 15:28
Click modular router: example of non element compilation file
InfiniteSource(LIMIT 1)
-> UserElem()
-> Discard;