Skip to content

Instantly share code, notes, and snippets.

Amir Kadivar amirkdv

Block or report user

Report or block amirkdv

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
amirkdv /
Last active Jun 8, 2018
An Evolutionary Model for the Emergence of Scale-Free Biological Networks
#!/usr/env/bin python3
# USAGE: LIB=work_space python3
import random
import sys
import itertools
import math
import networkx as nx
import numpy as np
import os
from ctypes import cdll
amirkdv /
Last active Jun 8, 2018
Statistical Analysis of Coherence in LFP recordings
#!/usr/bin/env python
import sys
import numpy as np
from numpy.fft import rfft, rfftfreq, irfft
from matplotlib import pyplot as plt
from scipy.signal import csd, welch
# install via `pip install git+`
from wavelets import WaveletAnalysis
amirkdv / Allocate
Last active Aug 29, 2015
Generate deterministic *nix ports for services
View Allocate

Example usage:

$ python
usage: [-r|--resolve] NAME

$ python

$ python
port 31079 is in use by 'nc' (pid: 28569), use --resolve

In a fresh checkout:

cat provision
# #!/bin/bash
# echo step 1 >> /report.log
# echo step 2 >> /report.log

docker build -t entrypoint-exp01 .
# ...
amirkdv /
Last active Aug 29, 2015
Cleanly run commands that require mysql running
# Executes the provided arguments as a shell command with a twist: if mysql is
# not already running: starts mysql, runs the commands, and stops mysql.
# Example usage:
# - mysqldo mysql -u root -p # will open an interactive shell and will stop mysql
# # when you leave the shell
# - mysqldo 'echo "show databases;" | mysql -u root -p"my_password"'
# # note that if your commands involve pipes or anything that the shell
# # interpretter would not pass to mysqldo as arguments, you should wrap the
# # entire command in quotes.
amirkdv / Transparent Proxy to docker
Last active Dec 13, 2017
Transparent Proxy to docker containers
View Transparent Proxy to docker

This is an example of using Linux Kernel's Transparent Proxy to route all TCP traffic to docker containers without having to resort to PROXY protocol which is not supported by some applications (e.g. sshd). To get the demo to work you only need vagrant installed:

git clone [this-gist] tproxy-demo
cd tproxy-demo
vagrant up
amirkdv /
Last active Nov 20, 2015
Simple HTTP monitor

POC simple HTTP monitoring script. First build the docker images:

git clone [this-gist] monitor
cd monitor
docker build -t amirkdv/monitor .

Now start the container, and all sites under sites.yaml will be pinged one after another:

docker run -i -t amirkdv/monitor
amirkdv /
Last active Jun 6, 2019
Backup an LVM logical volume via Rsync
# Backup an entire LVM logical volume via a snapshot LV and rsync
[[ $( whoami ) != 'root' ]] && echo "sudo please" && exit 1
set -o errexit
set -o nounset
# LVM logical volume to backup
You can’t perform that action at this time.