Skip to content

Instantly share code, notes, and snippets.

@gabrii
gabrii / FOO
Last active March 21, 2017 17:36
Pseudo random number & series generator, consistent across python 2.x and 3.x based on SHA
11
# HELLO WORLD# HELLO WORLD# HELLO WORLD# HELLO WORLD# HELLO HELLO WORLD# HELLO WORLD# HELLO WORLD# HELLO WORLD# HELLO WORLD# HELLO WORLD# HELLO WORLD# HELLO WORLD# HELLO WORLD# HELLO WORLD# HELLO WORLD# HELLO WORLD# HELLO WORLD# HELLO WORLD# HELLO WORLD# HELLO WORLD# HELLO WORLD# HELLO WORLD# HELLO WORLD# HELLO WORLD# HELLO WORLD# HELLO WORLD# HELLO WORLD# HELLO WORLD# HELLO WORLD# HELLO WORLD# HELLO WORLD# HELLO WORLD
@gabrii
gabrii / symbolencoder.py
Created May 2, 2015 09:47
Algorithm to encode any text in the optimal chemical symbols representation. Full article at http://gabgav.com/writing-with-elements/
# import elements database
from periodic import elements
# Exclude last 6 new elements, which have 3 letters provisional names
# And parse everything into a tuples array
elements = [(element.symbol, element.name) for element in elements[:-6]]
def print_elements(elements_array):
"""Prints an array of elements with brackets, and prints fake elements as normal text"""
@gabrii
gabrii / wv.py
Last active August 29, 2015 14:16
from bs4 import BeautifulSoup
s = '''STRING CON TODO EL HTML CONTENIDO EN LA ETIQUETA <div class="message-list"...> de http://web.whatsapp.com/'''
s = BeautifulSoup(s)
s = s.findAll('div', {'class':'bubble bubble-text'})
votes = {}
for l in s:
try:
from bs4 import BeautifulSoup
s = '''STRING CON TODO EL HTML CONTENIDO EN LA ETIQUETA <div class="message-list"...> DE http://web.whatsapp.com/ DEL GRUPO CON TODOS LOS MENSAJES CARGADOS'''
s = BeautifulSoup(s)
s = s.findAll('div', {'class':'bubble bubble-text'})
votes = {}
for l in s:
try:
@gabrii
gabrii / particledope.py
Created December 23, 2013 17:23
Particles simualtion with Coulomb's Law and cubic gravitational law ( like the normal gravitation law, but with r³ instead of r²). This simulation does not have any phisical meaning, it's just for fun. See some captures at: http://sta.sh/21s1a54ox37m
#! /usr/bin/env python
'''
Controls:
Adding particles (and it's charges):
left button -> (+)
right button -> (-)
middle button -> ( )
SPACE : Play/pause
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sunburnt
import nltk
import urlparse
from StringIO import StringIO
import re
from color import *
import threading
import time
@gabrii
gabrii / format_number.py
Created October 29, 2013 18:21
Pyhton number formating
# Original code from: http://stackoverflow.com/questions/5807952/removing-trailing-zeros-in-python
import decimal
import random
def format_number(num):
try:
dec = decimal.Decimal(num)
except:
return 'bad'
tup = dec.as_tuple()
@gabrii
gabrii / re_email.py
Created October 18, 2013 17:36
Regular Expression for matching emails.
re.match(r"^[A-Za-z0-9\.\+_-]+@[A-Za-z0-9\._-]+\.[a-zA-Z]*$", email)
@gabrii
gabrii / gh_userchecker.py
Created September 22, 2013 17:43
Checks github usernames availability of a list of usernames.
from httplib2 import Http
# Exemple of usernames list (all combinations of 3 letters from a to z):
from string import letters
letters = letters[:26]
usernames = [ a+b+c for a in letters for b in letters for c in letters]
h = Http()