Skip to content

Instantly share code, notes, and snippets.

View paparomeo's full-sized avatar

Pedro Romano paparomeo

  • Pedro Romano
  • Portugal
View GitHub Profile
@paparomeo
paparomeo / cons-car-cdr.py
Created November 5, 2018 21:39
cons / car / cdr
Python 3.7.0 (default, Jun 29 2018, 20:14:27)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.5.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: def cons(a, b):
...: def pair(f):
...: return f(a, b)
...: return pair
In [2]: p = cons(1, 2)
function nvm
bass source /usr/share/nvm/init-nvm.sh ';' nvm $argv
end

Keybase proof

I hereby claim:

  • I am paparomeo on github.
  • I am paparomeo (https://keybase.io/paparomeo) on keybase.
  • I have a public key whose fingerprint is 2D0F 26D1 212E 0349 FCA7 F90A C686 52AA 9CC2 B0F9

To claim this, I am signing this object:

@paparomeo
paparomeo / gist:4111194
Created November 19, 2012 15:11
A Comparative Study of MySQL and MongoDB

MongoDB vs MySQL

A Comparative Study by Pedro Romano

MySQL is a traditional Relational Database Management System (RDBMS) using the Standard Query Language (SQL) for data querying and manipulation of the database schema. MongoDB, on the other hand, is a document-oriented database,

@paparomeo
paparomeo / uuid_short_primary_key_sa.py
Created November 3, 2012 12:33
UUID_SHORT default for MySQL on SQLAlchemy
#!/usr/bin/env python3
from sqlalchemy import BigInteger, Column, create_engine, DDL, event
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from sqlalchemy.schema import FetchedValue
from sqlalchemy.sql.expression import func
Base = declarative_base()
@paparomeo
paparomeo / gist:3878125
Created October 12, 2012 08:45
Unused stackoverflow post.
From the information provided in your question and comments, I am assuming that the script, although developed on Linux, will be running on Windows, since this answer is dependent on the [pywin32][1] package which will only run on Windows. You can find the pywin32 package documentation [here][2]. It is assumed that the [pywin32][1] is installed and available.
The [win32print][3] module provides the functionality for enumerating and printing to shared Windows (or Samba) printers.
To enumerate the printers shared from a server use:
import win32print
win32print.EnumPrinters(win32print.PRINTER_ENUM_NAME, r'\\server-name')
@paparomeo
paparomeo / catalog-locale-as-a-property.patch
Created September 13, 2012 00:48
Alternative approach with locale as a property with a setter
--- a/babel/messages/catalog.py Mon Aug 27 21:15:27 2012 +0000
+++ b/babel/messages/catalog.py Thu Sep 13 01:44:20 2012 +0100
@@ -203,7 +203,16 @@
class Catalog(object):
- """Representation of a message catalog."""
+ """Representation of a message catalog.
+
+ .. py:attribute:: num_plurals
@paparomeo
paparomeo / cm_demo.py
Created September 6, 2012 13:37
Class methods demo.
#!/usr/bin/env python3
from abc import ABCMeta, abstractclassmethod
class Animal(metaclass=ABCMeta):
def __init__(self, name):
self.name = name