Skip to content

Instantly share code, notes, and snippets.

View theist's full-sized avatar
🐼

Carlos Peñas San José theist

🐼
View GitHub Profile
@theist
theist / gist:1730322
Created February 3, 2012 14:05
redirect test script
url = ARGV.shift
redirect = true
while redirect do
redirect = false
status = ""
location = "<none>"
curl = `curl -s -I #{url}|dos2unix`
@theist
theist / hamster-what.pl
Created July 24, 2012 07:52
Hamster activity print
#!/usr/bin/perl -w
#
use strict;
use Net::DBus;
eval {
my $bus = Net::DBus->find;
my $hamster = $bus->get_service("org.gnome.Hamster");
my $hamster_manager = $hamster->get_object("/org/gnome/Hamster","org.gnome.Hamster");
@theist
theist / rtr.rb
Created September 24, 2012 06:08
Facebook id checker
require 'fb_graph'
ids = File.new('data').readlines;
for id in ids do
tm = id.split(';')
user = tm[2]
begin
fbu = FbGraph::User.new(user)
fbu.fetch()
@theist
theist / parador.rb
Created January 31, 2013 17:30
Para Arranca y lista maquinas de amazon. es un gist, no busques el readme, seria mas largo que el codigo
#!/usr/bin/env ruby
#
require 'yaml'
require 'rubygems'
require 'fog'
require 'thor'
require 'colorize'
class Main < Thor
@theist
theist / gist:6120577
Created July 31, 2013 09:09
Munin node client, extracts every value from every plugin available in a munin node passed as parameter and print it in a carbon like format. Intended to extract munin node stats and push it to cabon in a cron call like ./simple_munin_node_client.pl munin_host | nc carbon_host 2004
We couldn’t find that file to show.
@theist
theist / install-graphite-ubuntu-11.10.sh
Last active May 17, 2017 11:31
Changed to choice between "local" and EC2 setup. To do a local setup yo will do id_rsa created and authorized in your user. Your user must also possess sudo with no password (user or usergroup ALL=(ALL:ALL) NOPASSWD: ALL) This is useful to make local tests and changes to setup without wasting EC2 resources
#!/bin/bash
####################################
# BASIC REQUIREMENTS
# http://graphite.wikidot.com/installation
# Forked from: http://geek.michaelgrace.org/2011/09/how-to-install-graphite-on-ubuntu/
# Ubuntu 11.10 Oneiric Ocelot
# Forked from https://gist.github.com/1287170
# Modified to use NGinx + uwsgi instead of Apache, as well as memcached and supervisord, incorporating ideas from
# http://blog.adku.com/2011/10/scalable-realtime-stats-with-graphite.html
@theist
theist / log_to_yaml.pl
Last active August 29, 2015 13:56
method
my $requests = 0;
my %status;
my %type;
my %method;
my %kind;
while (<>) {
next if (/request: /);
next if (/\[(info|warn)\]/);
@theist
theist / Geocities.pl
Last active August 29, 2015 14:00
GeoLiteCity to ngx geo
#!/usr/bin/perl -w
#
sub dec2ip ($) {
join '.', unpack 'C4', pack 'N', shift; # copied from the hive mind
}
open (LOCS, '<GeoLiteCity-Location.csv');
my %es_locs;
@theist
theist / group_file.pl
Created October 1, 2014 09:20
gam script creator
#!/usr/bin/perl
my $group = shift;
my @users = ();
my $gam_call = "python gam.py";
die "please specify a group" unless $group;
while (<>) {
@theist
theist / andalucia.rb
Last active August 29, 2015 14:17
Commandline andalucia's realtime results
require 'json'
require 'rest-client'
participacion_url = 'http://resultados-elecciones.rtve.es/andalucia/multimedia/json/2015/participacion/andalucia/2015-participacion-andalucia.json'
partidos_url = 'http://resultados-elecciones.rtve.es/andalucia/multimedia/json/2015/resultados/andalucia/2015-resultados-andalucia.json'
partidos = JSON.parse(RestClient.get(partidos_url))
participacion = JSON.parse(RestClient.get(participacion_url))
%w(escrutado_porcentaje en_blanco_porcentaje abstencion_porcentaje nulos_porcentaje).each do |data|