This file contains 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
# -*- coding: utf-8 -*- | |
__author__ = "Antonio Ribeiro Alves Júnior" | |
__date__ = "Sept/2010" | |
__license__ = "Creative Commons" | |
__contact__ = "alvesjunior.antonio [at] gmail [dot] com" | |
class Serial: | |
def create_stream(self,frase): | |
"""Cria o stream serial binário para uma determinada cadeia de caracteres de entrada""" |
This file contains 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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
__author__ = "Antonio Ribeiro Alves Júnior" | |
__date__ = "Sept/2010" | |
__license__ = "Creative Commons" | |
__contact__ = "alvesjunior.antonio [at] gmail [dot] com" | |
class Serial: | |
def __init__(self,parity=0,start=1,stop=1): | |
self.parity = parity |
This file contains 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
/** | |
License: Creative Comons | |
Author: Antonio Ribeiro Alves júnior | |
**/ | |
#include <math.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
int *primo(int v) |
This file contains 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
from isisdm.mapper import Document | |
from isisdm.mapper import TextField, NumberField, DateTimeField | |
class Livro(Document) | |
titulo = TextField(required=True, repeatable=True) | |
data = DateTimeField() | |
total_paginas = NumberField() |
This file contains 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
#Example: attaching file using couchdbkit | |
import couchdbkit | |
f = open('/tmp/file') #it works if you have a file with this name dude! | |
doc = {'text':'My Attachment'} | |
s = couchdbkit.Server() | |
db = s.get_or_create_db('blah') |
This file contains 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 fibo(n): | |
if n==0 or n==1: | |
return n | |
else: | |
return fibo(n-1)+fibo(n-2) | |
def fibo2(n): | |
if n==0 or n==1: | |
return n | |
n -= 1 |
This file contains 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 MyList(list): | |
def __and__(self, other): | |
op = str(bin(other)[2:]) | |
op = op.zfill(len(self))[::-1] | |
acc = [] | |
for count,i in enumerate(op): | |
if int(i): | |
acc.append(self[count]) | |
return acc |
This file contains 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 sqlalchemy | |
engine = sqlalchemy.create_engine('sqlite:///:memory:', echo=False) | |
from sqlalchemy.ext.declarative import declarative_base | |
from Crypto.Hash import SHA256 | |
from sqlalchemy.orm import relationship, backref | |
Base = declarative_base() | |
class User(Base): | |
This file contains 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
from sqlalchemy import * | |
from sqlalchemy.ext.declarative import declarative_base | |
from sqlalchemy.orm import relationship, backref, sessionmaker | |
engine = create_engine('sqlite:///:memory:', echo=False) | |
Session = sessionmaker(bind=engine) | |
session = Session() | |
metadata = MetaData() | |
Base = declarative_base() |
This file contains 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
#coding: utf-8 | |
text = """No te amo como si fueras rosa de sal, topacio | |
o flecha de claveles que propagan el fuego | |
te amo como se aman ciertas cosas oscuras, | |
secretamente, entre la sombra y el alma. | |
Te amo como la planta que no florece y lleva | |
dentro de sí, escondida, la luz de aquellas flores, | |
y gracias a tu amor vive oscuro en mi cuerpo | |
el apretado aroma que ascendió de la tierra. |
OlderNewer