Skip to content

Instantly share code, notes, and snippets.

View lvidarte's full-sized avatar

Leo Vidarte lvidarte

View GitHub Profile
@lvidarte
lvidarte / logs_purge.py
Last active August 29, 2015 14:09
Borra todo índice de logstash dejando solo los últimos 10
import requests
logstash_url = 'http://localhost:9200'
indices_limit = 10
response = requests.get('%s/_stats' % logstash_url)
data = response.json()
def get_logstash_indices(data):
return [indice for indice in sorted(data['indices']) if indice.startswith('logstash')]
char c;
int led = 4;
int counter = 0;
void setup()
{
Serial.begin(57600);
pinMode(led, OUTPUT);
}
@lvidarte
lvidarte / aws.sh
Created December 24, 2014 13:23
Tmux script for connect to aws servers
#!/bin/bash
SESSION=aws
SSH="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ~/.ssh/it-coquelux.pem ubuntu"
FIRST=1
for SERVER in $@
do
if [ $FIRST -eq 1 ]
then
@lvidarte
lvidarte / aws.sh
Last active August 29, 2015 14:12
Open all webservers on tmux session
#!/bin/bash
SESSION=aws
FIRST=1
SSH="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ~/.ssh/it-coquelux.pem ubuntu"
IPS=`aws ec2 describe-instances \
--filter 'Name=tag:Name,Values=WEBSERVER' \
--output text \
--query 'Reservations[*].Instances[*].PublicIpAddress'`
@lvidarte
lvidarte / sketch.ino
Created December 26, 2014 17:37
Mini Servo sg90
#include <Servo.h>
#define SERVO_PIN 9
Servo myServo;
byte i;
void setup()
{
@lvidarte
lvidarte / blink.js
Created January 11, 2015 01:02
Arduino blink with cylon.js
@lvidarte
lvidarte / aws-update-hosts.py
Last active August 29, 2015 14:13
Read hosts file and replace webservers hosts with the ips passed by arguments
#!/usr/bin/python
import sys
filename = '/etc/hosts.backup'
delimiter = '##aws-webservers'
if len(sys.argv) == 1:
print "Missing arguments"
@lvidarte
lvidarte / aws-get-instances.sh
Created January 21, 2015 18:01
Get aws webserver instances
#!/bin/bash
aws ec2 describe-instances --filter 'Name=tag:Name,Values=WEBSERVER' --output text --query 'Reservations[*].I nstances[*].PublicIpAddress'
@lvidarte
lvidarte / aws-update-hosts.sh
Created January 21, 2015 18:05
Make hosts backup and save the updated hosts on /etc/hosts
#!/bin/bash
sudo cp /etc/hosts /etc/hosts.backup \
&& python aws-update-hosts.py `aws-get-instances.sh` | sudo tee /etc/hosts