Skip to content

Instantly share code, notes, and snippets.

@jalexandre0
jalexandre0 / filecounter.py
Last active December 16, 2015 15:09
File counter to use when your run low of inodes and your system has only one partition. It is ugly, unpolished, unfinished and works perfectly for me ;)
#!/usr/bin/env python
import os
import sys
root_dir = str(sys.argv[1])
total = 0
def look_dirs(root_dir):
dir_list = []
@jalexandre0
jalexandre0 / zabbix.blockdevices.discovery.pl
Last active December 16, 2015 15:19
Perl quick and dirty to get blockdevices. Used only in zabbix low level discovery. Its ugly, and works for me and... oh, wait, its perl. :D
#!/usr/bin/perl
$first = 1;
print "{\n";
print "\t\"data\":[\n\n";
#Need fix here. Proc Partitions to rescue
for (`/usr/bin/iostat -d 1 1 | grep -v Device | grep -v Linux| awk '{print \$1}' | sed '/^\$/d' `)
{
chomp $_ ;
print "\t,\n" if not $first;
$first = 0;
@jalexandre0
jalexandre0 / zabbix.housekeeping.sh
Created April 24, 2013 19:05
Housekeeping for postgresql and zabbix. I'm still using this after zabbix 2.0, and still working.
#Setting atual date
echo $(date +%d/%m/%Y-%H:%M)
#One year and month ago in Unix Timestamp
ONE_YEAR_AGO=$(expr `date +%s` - 31536000)
ONE_MONTH_AGO=$(expr `date +%s` - 2678400)
#Queries for one month ago
MONTH_TABLES="history history_uint history_str history_text history_log"
for table in $MONTH_TABLES
@jalexandre0
jalexandre0 / check_internet.py
Last active December 16, 2015 20:00
###WIP### Check internet and change default routes if three sites are down.
#!/usr/bin/env python
import urllib2
import subprocess
import commands
debug = 1
def open_url(url):
try:
@jalexandre0
jalexandre0 / iptracker.sh
Last active December 17, 2015 13:49
Ip tracker when you can't use dyndns
#!/bin/bash
IP=$(curl -s ifconfig.me)
LAST_IP=$(cat /tmp/myip )
if [ "$IP" = "$LAST_IP" ]
then exit 0
else echo $IP > /tmp/myip ; echo $IP | mail -s "Valid IP for host XPTO" notifications@company.com
fi
@jalexandre0
jalexandre0 / code_sample.pl
Created May 21, 2013 14:48
Collections of perl utils and one-liners I use this for personal reference (Yep, TDAH)
#Open File
$input_fh, "<users.txt" or die "Can't open the file" ; close $input_fh ;
# Insert lines into array
while ( $line = <$input_fh> ) { push @array,$line ; }
#Parsing CSV
foreach(@array) {
chomp $_ ;
($user, $password) = split /,/, $_ ;
// I´m arduino user, not a former programmer. If you have a better approach for brewery, do it!!
// If you found bugs, fix it and ping me. :)
//Libraries
#include <OneWire.h>
#include <DallasTemperature.h>
#include <PID_v1.h>
//Pin 2 for OneWire
//Pin 6 for Heat Element
#include <PID_v1.h>
#include <PID_AutoTune_v0.h>
#include <OneWire.h>
#include <DallasTemperature.h>
//Pins
#define RelayPin 6
#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

Keybase proof

I hereby claim:

  • I am jalexandre0 on github.
  • I am jalexandre (https://keybase.io/jalexandre) on keybase.
  • I have a public key whose fingerprint is DD28 0A67 03C1 3A2B 86E1 5580 7765 A07F F9AB B9A5

To claim this, I am signing this object:

@jalexandre0
jalexandre0 / massflash.py
Created February 17, 2017 17:39 — forked from geekman/massflash.py
automated ESP8266 programming station to mass flash large quantity of devices quickly
#!/usr/bin/env python
#
# automated ESP8266 programming station
# monitors for inserted serial devices and calls esptool to flash them
# written to mass flash entire batches of ESP8266 devices quickly
# $ pip install esptool pyudev
#
# 2016.06.16 darell tan
#