This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class fraction: | |
"""This class provides fraction representation and basic operation (+, -, * and /). Operations can be done with fractions and whole numbers)""" | |
def __init__(self, numerator, denominator = 1): | |
"""To create a fraction, you can use either numerator and denominator, or only the numerator. | |
If you give only one decimal number, the find_fraction method will find the appropriate fraction.""" | |
self.numerator = numerator | |
self.denominator = denominator | |
if str(self.numerator).find(".") != -1: | |
self.find_fraction() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class myhash: | |
"""A VERY unefficient checksum. Works well with strings and tiny files (<1MB)""" | |
hexa = ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'] | |
def __init__(self, content = ""): | |
self.content = content | |
self.checksum = ['0']*32 | |
self.position = 0 | |
self.update(self.content) | |
def digest_one(self, to_digest): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#This program enable you to generate pronounceable - not always i admit - words with custom and/or random properties. It can for instance be used to make passwords which are easy to memorize. | |
import random | |
###Vars. You can freely add vowels, consonant and syllabes without changing the program | |
v = ['b','c','d','f','g','h','j','k','l','m','n','p','q','r','s','t','v','w','x','y','z'] | |
c = ['a','e','i','o','u'] | |
s = [] | |
for a in v: | |
for b in c: | |
s.append(a+b) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Python Brainfuck interpreter, made by RK11 | |
#Version 0.2 | |
#Changelog: | |
#0.1> First version | |
#0.2> Better output, and debug mode | |
import sys, time | |
class bf: | |
def __init__(self, input_bf, debug = False): | |
self.input = input_bf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def all_posibilities(max_length, letters): | |
result = [] | |
for length in range(1, max_length+1): | |
pos = [0]*length | |
actual_word = "" | |
limit = (len(letters))**length | |
nbr_of_words = 0 | |
while nbr_of_words < limit: | |
for char in range(length): | |
actual_word = letters[pos[char]] + actual_word |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib2, urllib | |
number_of_result = 20 | |
def get_page(query): | |
page_source = urllib2.urlopen("http://mp3skull.com/mp3/{}.html".format(query.replace(" ","_"))).read() | |
return page_source | |
def get_link(page_source, n): | |
# "n" is the position in the list in the results |