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
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"),
# https://askubuntu.com/questions/646850/vmware-5-player-ubuntu-14-04-guest-autofit-open-vm-tools/763131#763131
sudo apt install open-vm-tools open-vm-tools-desktop
vmtoolsd -n vmuser
vmware-user-suid-wrapper
import subprocess
import json
import logging
import os
logger = logging.getLogger(__name__)
from django.conf import settings
if not settings.DISABLED_REMOTE_ENGINE:
import salt.client
@martinrusev
martinrusev / main.go
Created February 5, 2016 08:24 — forked from manishtpatel/main.go
GoLang Encrypt string to base64 and vice versa using AES encryption.
package main
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"encoding/base64"
"fmt"
"io"
)
@martinrusev
martinrusev / the-rust-wilderness.md
Last active January 21, 2016 21:26
My thoughts on Rust

The Rust Wilderness

There is a lot of confusion out there, when it comes to Go and Rust. People often make comparisons between the two languages and it is very difficult to see the differences until you invest some of your time with each language.

On first glance, Go seemed restrictive and Rust was checking all the feature boxes I wanted in a system programming language.

I started experimenting with both languages and this is what I learned (Spoiler: They don't have much in common):

@martinrusev
martinrusev / gist:71eb4303663dd85a8463
Created January 15, 2016 11:52
amon_cloudwatch_metrics
CLOUDWATCH_METRICS = [
'DiskWriteBytes',
'DiskReadBytes',
'NetworkOut',
'NetworkIn',
'DiskReadOps',
'DiskWriteOps',
'CPUUtilization'
]
curl -s -w 'ping.amoncx.lookup_time:%{time_namelookup}|gauge
ping.amoncx.connect_time:%{time_connect}|gauge
ping.amoncx.total:%{time_total}|gauge\n' -o /dev/null https://www.amon.cx
@martinrusev
martinrusev / generate_self_signed_cert.sh
Last active December 20, 2015 12:21
Generate a self signed certificate with 2 lines
openssl req -new -newkey rsa:2048 -nodes -out star_localhost.csr -keyout star_localhost.key -subj "/C=BG/ST=Sofia/L=Sofia/O=Amon/OU=Marketing/CN=*.localhost"
openssl x509 -req -days 365 -in star_localhost.csr -signkey star_localhost.key -out star_localhost.crt
# 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