Skip to content

Instantly share code, notes, and snippets.

@alan-mushi
alan-mushi / ripe_test.ex
Last active Jul 15, 2020
Ripe inetnum elixir parsing (OOM-killer)
View ripe_test.ex
# 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 Feb 12, 2016
Simple benchmark on functions using loggers and decorators.
View benchmark.log
__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 Feb 9, 2016
Simple Encryption/Decryption in Thunar's contextual menu
View thunar-openssl-encrypt.sh
#!/bin/sh
usage() {
echo "$0 -f <filename>"
echo
echo " required:"
echo " -f input filename"
echo
}
@alan-mushi
alan-mushi / easy-graphviz.py
Created Dec 26, 2015
Easy graphviz for a simple graph in Python 3
View easy-graphviz.py
# 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 Dec 19, 2015
Generate a HTML page from markdown files with Bootstrap CSS
View markdown_with_bootstrap_css.sh
#!/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 Dec 2, 2015
SRI TP scapy TCP connect dumb scanner
View scan.py
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 Nov 8, 2015
This simple helper script toggle the mute attribute for a program in pulseaudio.
View pulseaudio_toggle_mute.sh
#!/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'
View DummyAnswer.cc
#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 Nov 21, 2016
Click modular router: example of non element compilation file
View hello.click
InfiniteSource(LIMIT 1)
-> UserElem()
-> Discard;