Skip to content

Instantly share code, notes, and snippets.

View paulohrpinheiro's full-sized avatar
🏠
Working from home

Paulo Henrique Rodrigues Pinheiro paulohrpinheiro

🏠
Working from home
View GitHub Profile
@paulohrpinheiro
paulohrpinheiro / how_many.py
Created April 4, 2017 14:27
Quantos números aleatórios gero em 1 segundo? - Python
import sys
import random
import signal
def handler(signum, frame):
print(how_many)
sys.exit()
signal.signal(signal.SIGALRM, handler)
@paulohrpinheiro
paulohrpinheiro / how_many.rb
Created April 4, 2017 14:15
Quantos números aleatórios gero em 1 segundo? - Ruby
# frozen_string_literal: true
require 'timeout'
how_many = 0
rand_generator = Random.new
begin
Timeout.timeout(1) do
loop do
@paulohrpinheiro
paulohrpinheiro / main.rs
Created January 15, 2017 17:25
Arquivos para o texto # Rust Pills - resolvendo nomes por DNS
[package]
name = "resolver"
version = "0.1.0"
authors = ["Paulo Henrique Rodrigues Pinheiro <paulohrpinheiro@gmail.com>"]
[dependencies]
libc = "0.2.8"
@paulohrpinheiro
paulohrpinheiro / gera_blog.rb
Created December 28, 2016 03:45
The ancestral script for this project: https://github.com/paulohrpinheiro/gerablog
#!/usr/bin/env ruby
require 'redcarpet'
require 'rss'
def write_file(filename, content, description, meta)
File.write(
filename,
%(<!--#include virtual="/parts/header_begin.html" -->\n\n) +
"#{meta}\n" +
@paulohrpinheiro
paulohrpinheiro / minhas_palavras.rb
Created December 17, 2016 02:53
Quais são as palavras que você mais usa no twitter?
#!/usr/bin/env ruby
require 'twitter'
require 'words_counted'
def collect_with_max_id(collection=[], max_id=nil, &block)
response = yield(max_id)
collection += response
response.empty? ? collection.flatten : collect_with_max_id(collection, response.last.id - 1, &block)
end
//! Crawler — My own crawler in Rust!
extern crate hyper; // biblioteca (crate) não padrão
use std::env; // argumentos env::args
use std::io::{Read, Write}; // para IO de arquivos
use std::fs::File; // para criar arquivos
use std::path::Path; // configurar nome de arquivo
use std::thread; // concorrência
//! Crawler — My own crawler in Rust!
extern crate hyper; // biblioteca (crate) não padrão
use std::env; // argumentos env::args
use std::io::{Read, Write}; // para IO de arquivos
use std::fs::File; // para criar arquivos
use std::path::Path; // configurar nome de arquivo
use std::thread; // concorrência
@paulohrpinheiro
paulohrpinheiro / Makefile
Created February 22, 2016 13:10
Fedora rpm spec for unqlite
DESTDIR=/usr/local
LIBDIR=$(DESTDIR)/lib
INCLUDEDIR=$(DESTDIR)/lib
CFLAGS=
LIBVERSION=0.1
LIBNAME=libunqlite.so.$(LIBVERSION)
SOLIB=-shared -Wl,--build-id,-soname,$(LIBNAME) -o $(LIBNAME)
$(LIBNAME): unqlite.c
The MIT License (MIT)
Copyright (c) 2016 Paulo Henrique Rodrigues Pinheiro <paulo@sysincloud.it>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@paulohrpinheiro
paulohrpinheiro / 000_novice-problem.py
Last active December 28, 2016 17:43
Primeira lista de exercícios do Test Driven Learning - 000_novice-python3
"""
Test Driven Learning Project.
Desenvolva TDD e programação com TDD e programação!
Módulo novice.
The MIT License (MIT)
Copyright (c) 2016 Paulo Henrique Rodrigues Pinheiro <paulo@sysincloud.it>
Permission is hereby granted, free of charge, to any person obtaining a copy