Skip to content

Instantly share code, notes, and snippets.

View carlopires's full-sized avatar

Carlo Pires carlopires

  • Aldeia Global
  • Goiânia/Brazil
View GitHub Profile
@carlopires
carlopires / ISO3166.py
Created October 4, 2011 15:33
Python dict for ISO3166 country codes
# -o- coding: utf-8 -o-
# ISO3166 python dict
# oficial list in http://www.iso.org/iso/iso_3166_code_lists
ISO3166 = {
'AF': 'AFGHANISTAN',
'AX': 'ÅLAND ISLANDS',
'AL': 'ALBANIA',
'DZ': 'ALGERIA',
'AS': 'AMERICAN SAMOA',
@carlopires
carlopires / ISO639_2.py
Created October 4, 2011 16:06 — forked from austing/gist:779243
Python dict with ISO-639-2 language codes
# -o- coding: utf-8 -o-
# ISO639 python dict
# oficial list in http://www.loc.gov/standards/iso639-2/php/code_list.php
ISO639_2 = {
'ab': 'Abkhaz',
'aa': 'Afar',
'af': 'Afrikaans',
'ak': 'Akan',
'sq': 'Albanian',
@carlopires
carlopires / easy_daemon.py
Created October 24, 2011 17:57
Easy python daemon
# -*- coding: utf-8 -*-
"""
Created on 23/10/2011
@author: Carlo Pires <carlopires@gmail.com>
"""
import sys
import time
from daemon import DaemonContext
from daemon.runner import make_pidlockfile, is_pidfile_stale
@carlopires
carlopires / hanoi.py
Created October 25, 2011 10:31
Hanoi Towers
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on 25/10/2011
@author: Carlo Pires <carlopires@gmail.com>
"""
class Disco:
def __init__(self, tamanho):
self.tamanho = tamanho
@carlopires
carlopires / zmq_hello.py
Created October 29, 2011 17:34
Right way to connect with mongrel2 server REQ/REP
# FROM: https://github.com/zeromq/pyzmq/issues/132
#
# You need to set LINGER to something other than -1 (the default) if
# you want the socket to stop trying to send. The gist is that you
# should be able to do:
#
# socket.send('foo')
# socket.close()
#
# and close() will block until the socket is done sending messages.
@carlopires
carlopires / redis_session_store.py
Created December 9, 2011 15:22
Werkzeug Redis Session Store
# -*- coding: utf-8 -*-
"""
Created on 09/11/2011
@author: Carlo Pires <carlopires@gmail.com>
"""
import tnetstring
from werkzeug.contrib.sessions import SessionStore
SESSION_TIMEOUT = 60*60*24*7 # 7 weeks in seconds
@carlopires
carlopires / index-text-with-redis.py
Created December 16, 2011 17:42
Indexing Redis with Python
# -*- coding: utf-8 -*-
"""
Created on 16/12/2011
@author: Carlo Pires <carlopires@gmail.com>
"""
import json
from redis import Redis
r = Redis()
@carlopires
carlopires / bootstrap-plugins.txt
Created January 18, 2012 12:30 — forked from mklabs/bootstrap-plugins.txt
h5bp + twitter bootstrap integration
bootstrap-tooltip.js
bootstrap-popover.js
bootstrap-alert.js
bootstrap-button.js
bootstrap-carousel.js
bootstrap-collapse.js
bootstrap-dropdown.js
bootstrap-modal.js
bootstrap-scrollspy.js
bootstrap-tab.js
@carlopires
carlopires / demo_oci.php
Created February 25, 2013 20:52
Demo of using PHP OCI in a Oracle server
<?php
$ORACLE_HOST = "127.0.0.1";
$ORACLE_PORT = "1521";
$ORACLE_SID = "mysid";
$ORACLE_USER = "myuser";
$ORACLE_PASSWORD = "mypass";
$ORACLE_DSN = "
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = $ORACLE_HOST)(PORT = $ORACLE_PORT))
@carlopires
carlopires / demo_oci_parameters.php
Created February 25, 2013 20:57
Demo of PHP OCI with parameters
<?php
$ORACLE_HOST = "127.0.0.1";
$ORACLE_PORT = "1521";
$ORACLE_SID = "mysid";
$ORACLE_USER = "myuser";
$ORACLE_PASSWORD = "mypass";
$ORACLE_DSN = "
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = $ORACLE_HOST)(PORT = $ORACLE_PORT))