Skip to content

Instantly share code, notes, and snippets.

View rafapolo's full-sized avatar

Rafael Polo rafapolo

View GitHub Profile
@rafapolo
rafapolo / read_exif.rb
Created April 28, 2016 07:54
read exif metadata from uploaded pics on the browser
require 'sinatra'
set :port, 8080
set :bind, '0.0.0.0'
get "/" do
erb :index
end
get '/get_exif' do
@rafapolo
rafapolo / inspect-torrents-folder.coffee
Last active January 6, 2016 18:07
Gera JSON com infos de Seeds e Leechs no tracker OpenBittorrent para todo .torrent em uma pasta
#author: Rafael Polo
#language: CoffeeScript
#todo:
# remover repetidos
# considerar possíveis Peers vindos da DHT | distributed hash table
# parametrizar listar apenas com mais de 1 seed
# consultar outros Trackers usando API do torrentz.eu
Torrent = require('nt')
Tracker = require('node-tracker')
@rafapolo
rafapolo / get_content_from_page.rb
Created June 2, 2015 12:23
Get body content from django_CMS Page model
def db # connects to old database
Mysql2::Client.new(host: 'localhost', username: 'root', database: 'eti')
end
def select(from)
puts '='*20
exec = "SELECT * from #{from}"
puts exec
puts '='*20
db.query(exec)
@rafapolo
rafapolo / app.js
Created March 11, 2015 20:00
certcheck.me animations
$(document).ready(function() {
$(".item[cert='{{cert}}']").css('border', '5px solid #FFBD09');
$('.item').hover(
function(){
icon = $(this).children().children();
icon.attr('off', icon.attr('src'));
icon.attr('src', '/static/img/scary.svg');
},
function(){
icon.attr('src', icon.attr('off'));
@rafapolo
rafapolo / zeitbank.db.js
Last active August 29, 2015 14:11
zeitbank database #1
// this is the zeitbank database #1
// filled during the gütermarkt #3
// to do:
// - server-side script to serve this file - the people database
// - show last_updated_ago
// - cliente-side script to read it and render as a CNN news style
// - convert type face to web version // ask jolanda
people = [
@rafapolo
rafapolo / dataviz.rb
Created November 27, 2014 16:53
Convert Jeff's .XLS into a .DOT Graph file
#!/usr/bin/env ruby
#encoding: utf-8
#comment: Convert Jeff's .XLS into a .DOT Graph file
# configurations
file = "kenya.xls"
# columns to export as graph nodes
columns = ["Project", "Platform", "Developer", "Organization", "Funder", "Category", "Type"]
# how columns connect to each other
relations = {
@rafapolo
rafapolo / category_itens_per_col.rb
Last active August 29, 2015 14:07
define número de elementos por colunas
# backend
def category_itens_per_col(total)
return case total
when 0..3 then 1
when 4..6 then 2
when 7..9 then 3
else 4
end
end
@rafapolo
rafapolo / convert_large_1mb.sh
Created February 17, 2014 21:04
converte para 900px de largura toda imagem com mais de 1Mb
find . -size +1M | while read file_name; do sips $file_name --resampleWidth 900 ; done
@rafapolo
rafapolo / traduz.sh
Created January 15, 2014 21:54
traduz no terminal
#!/bin/bash
QUERY=$*
# Split Alfred query into parts:
SOURCE_LANGUAGE=`echo "$QUERY" | awk '{ print $1; }' `
DESTINATION_LANGUAGE=`echo "$QUERY"| awk '{ print $2; }' `
# Transform the text to something Google translate understands
set +o histexpand
@rafapolo
rafapolo / Preferences.sublime-settings
Last active December 31, 2015 12:09
sublime text improved preferences
{
"ensure_newline_at_eof_on_save": true,
"fade_fold_buttons": false,
"font_size": 9,
"highlight_line": true,
"line_padding_bottom": 1,
"line_padding_top": 1,
"tab_size": 2,
"translate_tabs_to_spaces": true,
"trim_automatic_white_space": true,