Skip to content

Instantly share code, notes, and snippets.

View martinrusev's full-sized avatar
🌱
01010110

Martin Rusev martinrusev

🌱
01010110
  • Berlin, Germany
View GitHub Profile
@martinrusev
martinrusev / debian_6_squeeze.sh
Last active July 20, 2018 19:15
Ansible install on Debian
echo 'deb http://http.debian.net/debian-backports squeeze-backports(-sloppy) main' > /etc/apt/sources.list.d/backports.list
apt-get update
apt-get -t squeeze-backports install "ansible"
@martinrusev
martinrusev / mint_to_ubuntu.sh
Created May 20, 2018 10:47
Replace Linux Mint references with Ubuntu
$ sudo vi /etc/linuxmint/mintSystem.conf
[global]
enabled = False
[restore]
lsb-release = False
etc-issue = False
$ sudo vi /etc/lsb-release
# kill all of the user processes
ps -u amonagent | grep -v PID | awk '{print $1}' | xargs -i kill {}
sleep 2
ps -u amonagent | grep -v PID | awk '{print $1}' | xargs -i kill {}
# Systemd
if which systemctl > /dev/null 2>&1 ; then
systemctl stop amonagent
# Sysv
else
@martinrusev
martinrusev / alb_example.tf
Created September 13, 2017 13:48
alb_example.tf
resource "aws_alb" "alb_grafana" {
name = "alb-energy-grafana"
internal = true
security_groups = ["${aws_security_group.sec_energy_grafana_elb.id}"]
subnets = ["${var.SUBNETS}"]
tags {
Name = "alb-energy-grafana"
Owner = "${var.OWNER}"
@martinrusev
martinrusev / docker_host_bridge.sh
Created June 1, 2017 13:26
Docker - Host bridge
# https://forums.docker.com/t/accessing-host-machine-from-within-docker-container/14248/5
docker network create -d bridge --subnet 192.168.0.0/24 --gateway 192.168.0.1 dockernet
# Now each container can connect to the host under the fixed IP 192.168.0.1.
@martinrusev
martinrusev / upload_certificate.sh
Created January 7, 2017 10:24
Upload Certificate to AWS IAM for use in Cloudfront
aws iam upload-server-certificate --server-certificate-name star_amon_cx --certificate-body file://star_amon_cx_body.cer --private-key file://star_amon_cx.key --certificate-chain file://star_amon_cx_chain.cer --profile personal --path /cloudfront/
import base64
import hashlib
from Crypto import Random
from Crypto.Cipher import AES
class AESCipher(object):
"""
A classical AES Cipher. Can use any size of data and any size of password thanks to padding.
Also ensure the coherence and the type of the data with a unicode to byte converter.
sum=0;
$('.tabellebg .tarifiert').each(function() {
val = $(this).html();
formatted_val = val.replace(".", "").replace(" kB", "").replace(" ", "");
val_to_int = parseInt(formatted_val);
if(!isNaN(val_to_int)) {
sum +=val_to_int;
}
import random
distros = ['debian', 'centos', 'rails', 'django', 'ubuntu','redis', 'mysql', 'mongo', 'db']
providers = ['do-ams','do-nyc', 'ec2-eu-west', 'ec2-us-east', 'do-ams', 'do-sf', 'do-sgp']
region = [1, 2, 3]
for i in range(5):
distro = random.choice(distros)
provider = random.choice(providers)
func main() {
cmd := os.Args[1] // the first argument is a command we’ll execute on all servers
hosts := os.Args[2:] // other arguments (starting from the second one) – the list of servers
results := make(chan string, 10) // we’ll write results into the buffered channel of strings
timeout := time.After(5 * time.Second) // in 5 seconds the message will come to timeout channel
// initialize the structure with the configuration for ssh packat.
// makeKeyring() function will be written later
config := &ssh.ClientConfig{
User: os.Getenv("LOGNAME"),