Skip to content

Instantly share code, notes, and snippets.

View romuloceccon's full-sized avatar

Rômulo Ceccon romuloceccon

  • Frankfurt am Main, Deutschland
View GitHub Profile
require 'net/http'
require 'nokogiri'
$uri = URI('http://bvmf.bmfbovespa.com.br/cias-listadas/empresas-listadas/BuscaEmpresaListada.aspx?idioma=pt-br')
def fetch_html(post_data)
req = Net::HTTP::Post.new($uri)
req.body = post_data
res = Net::HTTP.start($uri.hostname, $uri.port) { |http| http.request(req) }
@romuloceccon
romuloceccon / open-printscreen
Created December 2, 2016 15:54
Opens Byobu's printscreen file in a text editor from the command line
#!/bin/bash
[[ -z "$BYOBU_RUN_DIR" ]] && \
echo "Not a Byobu session!" 1>&2 && exit 1
[[ ! -e $BYOBU_RUN_DIR/printscreen ]] && \
echo "No printscreen found! (try pressing Shift+F7)" 1>&2 && exit 1
geany $BYOBU_RUN_DIR/printscreen
@romuloceccon
romuloceccon / google-finance-fetch
Last active November 6, 2016 15:31
Fetch financial statements from Google Finance
#! /usr/bin/env ruby
require 'bigdecimal'
require 'csv'
require 'net/http'
require 'nokogiri'
class CompanyStats
attr_reader :name
@romuloceccon
romuloceccon / Makefile
Last active November 18, 2016 09:32
Import a Ruby on Rails™ MySQL database dump (gzip compressed SQL) for use in a development environment using SQLite3
CFLAGS += -Wall
mysql2sqlite: mysql2sqlite.c
$(CC) $(CFLAGS) -o $@ $^
@romuloceccon
romuloceccon / byobu.desktop
Last active December 26, 2019 04:48
Gnome desktop launcher for starting Byobu with two vertical panes
[Desktop Entry]
Name=Byobu Terminal
Comment=Advanced Command Line and Text Window Manager
Icon=byobu
Exec=env BYOBU_WINDOWS=split2 gnome-terminal --app-id us.kirkland.terminals.byobu --window-with-profile=Byobu -e byobu
Type=Application
Categories=GNOME;GTK;Utility;
X-GNOME-Gettext-Domain=byobu
@romuloceccon
romuloceccon / b32backup.py
Last active September 24, 2016 20:16
A tool to convert small binary files to text suitable to be printed on paper. It uses Base32 encoding so that the result is easily parseable with OCR software and every line includes a CRC16 for error verification. Efficiency is about 3000 bytes per page using a 10-pt font!
#! /usr/bin/env python
# Examples:
#
## encoding
#
# $ head -c 135 /dev/urandom | b32backup.py
# ZLBD4SI6YCWDF63FYMQ4X7ZOORL5UYBOXZ4Y2WU54OKEQ4N5LBAFA7YHMYTC3W33KHCENWPK 13CB
# TUK5QT55AXF5PZL6Q6A5RJ7CJ24YZML3WMRQWAI6TCO5XGMOHJWAATO7TUCEM7BCL6FGTC6G 03AF
# 6SZVCA4CTBGIHZXC5DEGMCIOLRJPKGVIQCTWAQZAX4VMNLPULEJLWJMV6AAPIOPUYCVKEEIT 228A
require 'csv'
CSV do |out|
csv = CSV.new(STDIN)
csv.each do |row|
out << row.map do |x|
if m = x.match(/^\d+$/)
(m[0].to_i * 1.6).round.to_s
elsif m = x.match(/^(\d+)( m)(.*)$/)
(m[1].to_i * 1.6).round.to_s + ' km' + m[3]
@romuloceccon
romuloceccon / app_file_touched.rb
Created July 2, 2016 19:43
God condition to monitor files using inotify
module God
module Conditions
class AppFileTouched < TriggerCondition
def initialize
super
@mutex = Mutex.new
@queue = []
@condition = ConditionVariable.new
@thread = nil
end
@romuloceccon
romuloceccon / init_ssh_user.sh
Last active June 24, 2016 16:24
Initialize the .ssh dir of a user using credentials from another user (with root privileges)
# Copy and paste the following lines into a shell replacing $1 with the actual username.
# It will then ask for the public key to initialize the .ssh dir.
# The key will be appended to the authorized_keys file; current content (if any) will be preserved.
U=$1 ; H=$(eval echo ~$U) ; sudo mkdir -p $H/.ssh \
&& echo "Paste ssh key: (end with ^D)" \
&& cat > /tmp/$U_key.pub \
&& cat /tmp/$U_key.pub | sudo tee -a $H/.ssh/authorized_keys > /dev/null \
&& rm /tmp/$U_key.pub \
&& sudo chown $U:$U $H/.ssh \
@romuloceccon
romuloceccon / Gemfile
Last active April 24, 2016 13:21
Redis tests
gem 'redis'
gem 'json'