This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This software is inspired from | |
# https://gist.github.com/alastairmccormack/6517a8b94a52746af028 for which the | |
# original license is provided in respect its own expressed conditions. | |
''' | |
The MIT License (MIT) | |
Copyright (c) 2014 Al McCormack | |
Permission is hereby granted, free of charge, to any person obtaining a copy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import contextlib | |
import time | |
@contextlib.contextmanager | |
def report_time(test): | |
t0 = time.time() | |
yield | |
print("Time needed for `%s' called: %.2fs" % (test, time.time() - t0)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Start kubectl proxy | |
jobs &>/dev/null | |
kubectl proxy 2>/dev/null & | |
new_job_started="$(jobs -n)" | |
if [ -n "$new_job_started" ];then | |
kubeproxy_pid=$! | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
task(){ | |
start=$(python -c 'import time; print(time.time())') | |
echo "Running task with parameter $1" ; sleep 1 # to simulate work load | |
stop=$(python -c 'import time; print(time.time())') | |
processing_time=$(python -c "print(\"{:.2f}\".format(${stop} - ${start}))") | |
echo "process $2: $1 processed in ${processing_time} s" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Chitchat (no matter who serves) | |
machine1# nc -l 12345 | |
machine2# nc <ip> 12345 | |
# Sending a file | |
machine1# nc -l 12345 < /tmp/fichiersource | |
machine2# nc <ip> 12345 > /tmp/fichierrecu | |
# Works in either direction | |
machine1# nc -l 12345 > /tmp/fichiersource |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
import pickle | |
import gzip | |
import collections | |
class WritableDict(collections.MutableMapping): | |
'''A dict whose key/value pairs can be saved to/load from file. | |
Implements the interface of a dict thnaks to Abstract Base Classes''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
rsync -r -a --delete --append-verify --chown=username:groupname -v --progress --stats mydir username@server:/dest/path/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If not running interactively | |
if [ -z "$PS1" ]; then echo "This script must be sourced. Use \"source ./script.sh\" instead." ; exit ; fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If running interactively | |
if [ "$PS1" ]; then echo "This script cannot be sourced. Use \"./script.sh\" instead." ; return ; fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Copy-paste until EOF to setup Virtualenv | |
curl -s https://bootstrap.pypa.io/get-pip.py | sudo python | |
pip install -U virtualenv | |
pip install -U virtualenvwrapper | |
cat >> ~/.bashrc <<EOF | |
# virtualenv | |
export WORKON_HOME=~/.virtualenvs | |
mkdir -p \$WORKON_HOME | |
source /usr/bin/virtualenvwrapper.sh || source ~/.local/bin/virtualenvwrapper.sh |
NewerOlder