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 / 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|
[3] pry(main)> on roles(["all"]) do | h |
[3] pry(main)* puts h
[3] pry(main)* end
=> []
[4] pry(main)> on roles(["web"]) do | h |
[4] pry(main)* puts h
[4] pry(main)* end
192.168.10.185
=> [#<Thread:0x007f718ce572c0@/home/carlos/.rbenv/versions/2.2.0/gemsets/capistrano/gems/sshkit-1.7.1/lib/sshkit/runners/parallel.rb:11 dead>]
@theist
theist / redmine_filter.rb
Last active August 29, 2015 14:24
quick script for erase any redmine mail whose ticket id matches another containing also the word "Cerrada" or "Resuelta"
require 'gmail'
require 'rfc2047'
to_remove = []
gmail = Gmail.connect(username,password)
rmine = gmail.inbox.find(:from => redmine_address)
puts "processing #{rmine.count} messages"
@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