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 / ex_4_cap_3.hs
Last active December 29, 2015 11:44
Exercício 4 do capítulo 3 de Haskell: uma abordagem Prática, Cláudio Cesar de Sá & Márcio Ferreira da Silva
--ep4
fatorial x | (x==1) = 1
| otherwise = x * fatorial (x-1)
e_x x n | (n==0) = 1
| otherwise = ( (x**n) / fatorial n ) + (e_x x (n-1) )
delta x = delta' x 0
where delta' x n | (exp_x - (e_x x n)) < 0.001 = 0
| otherwise = 1 + delta' x (n+1)
@paulohrpinheiro
paulohrpinheiro / rand_one_second.py
Last active February 6, 2016 01:53
Quantos números pseuso-aleatórios posso gerar em um segundo?
import random
import signal, os
# Xupinskado de https://docs.python.org/2/library/signal.html#signal.setitimer
def handler(signum, frame):
print('Acabando....', signum)
raise NameError("Acaboooooouuuuuuuuu!!!!")
# Set the signal handler and a 1-second alarm
@paulohrpinheiro
paulohrpinheiro / 000_novice-solved.py
Last active February 15, 2016 00:41
Solução da 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 <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining a copy
@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 <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining a copy
The MIT License (MIT)
Copyright (c) 2016 Paulo Henrique Rodrigues Pinheiro <[email protected]>
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 / 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
//! 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 / 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
#!/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" +