Skip to content

Instantly share code, notes, and snippets.

View theist's full-sized avatar
🐼

Carlos Peñas San José theist

🐼
View GitHub Profile
[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 / selfsigned_to_aws.sh
Created December 17, 2015 10:21
This creates a selfsigned certificate/key pair an upload it to AWS iam for use in ELBs and the like
#!/bin/bash
DOMAIN=$1
openssl req -new -subj '/CN=${DOMAIN}/O=ACME./C=ES' -newkey rsa:2048 -days 365 -nodes -x509 -keyout ${DOMAIN}.key -out ${DOMAIN}.crt
if aws iam list-server-certificates --query "ServerCertificateMetadataList[*].ServerCertificateName" --output text | grep -q ${DOMAIN} ; then
aws iam delete-server-certificate --server-certificate-name ${DOMAIN}
fi
require "net/http"
require "json"
url = "http://resultadosgenerales2015.interior.es/congreso/results/ES201512-CON-ES/ES/info.json"
j=JSON.parse(Net::HTTP.get(URI(url)))
j['results']['parties'].each do |pa|
puts "#{pa['acronym']}: #{pa['seats']}" if pa['seats'] > 0
end
@theist
theist / circle_builds.rb
Last active March 23, 2016 09:39
CirclCI build list (not so tested)
#!/usr/bin/env ruby
require "colorize"
require "net/http"
require "json"
require "httparty"
token = '*****************************' # your API token here
class Build
@theist
theist / logstash.conf
Last active June 5, 2016 17:05
minimal logstash csv config
input { stdin { } }
filter {
csv {
}
}
output {
stdout { codec => rubydebug }
}
...
date {
# Set @timestamp
locale => "en_US"
match => ["BillingPeriodEndDate","yyyy/MM/dd HH:mm:ss"]
}
date {
target => "BillingPeriodStartDate"
locale => "en_US"
match => ["BillingPeriodStartDate","yyyy/MM/dd HH:mm:ss"]
csv {
columns => ["InvoiceID","PayerAccountId","LinkedAccountId","RecordType",
"RecordID","BillingPeriodStartDate","BillingPeriodEndDate",
"InvoiceDate","PayerAccountName","LinkedAccountName","TaxationAddress",
"PayerPONumber","ProductCode","ProductName","SellerOfRecord","UsageType",
"Operation","RateId","ItemDescription","UsageStartDate","UsageEndDate",
"UsageQuantity","BlendedRate","CurrencyCode","CostBeforeTax","Credits",
"TaxAmount","TaxType","TotalCost"]
convert => { "UsageQuantity" => "float" }
if [RecordType] not in ["LinkedLineItem","PayerLineItem"] {
drop {}
}
output {
if [date_error] in [tags] {
stdout { codec => plain }
} else {
stdout { codec => dots }
elasticsearch {
hosts => ["elasticsearch:9200"]
}
}
}