Skip to content

Instantly share code, notes, and snippets.

View ccarpenterg's full-sized avatar

Cristian Carpenter ccarpenterg

View GitHub Profile
<?xml version="1.0" encoding="ISO-8859-1"?>
<PurchaseOrder>
<Buyer>EuroTech</Buyer>
<ID>567701-134</ID>
<Date>07-08-09</Date>
<Currency>USD</Currency>
<Seller>Singapure Electronics</Seller>
<PODetails>
<Product>
<Model>Nokia 3G</Model>
#!/usr/bin/env python
'''
Autor: Cristian Carpenter G.
'''
from BeautifulSoup import BeautifulSoup
import urllib
import MySQLdb
from datetime import datetime
<serie symbol="CALICHERAA">
<entry high="825.0" close="812.280029296875" open="785.0" volume="4183662.0" low="775.0" variacion="4.810326360887096" date="09/06/2009"/>
<entry high="845.0" close="835.1099853515625" open="839.97998046875" volume="1.0945167E7" low="820.0" variacion="7.7561271421370925" date="10/06/2009"/>
<entry high="889.0" close="845.0999755859375" open="835.1099853515625" volume="3061376.0" low="835.0" variacion="9.045158140120968" date="11/06/2009"/>
CREATE TABLE acciones (
symbol VARCHAR(30) NOT NULL,
price DECIMAL(12, 4) NOT NULL,
volume DOUBLE NOT NULL,
date DATE NOT NULL
) engine = InnoDB;
#!/usr/bin/env python
'''
Autor: Cristian Carpenter G.
'''
from BeautifulSoup import BeautifulSoup
import urllib, re
import MySQLdb
from datetime import datetime
mysql> select * from acciones where symbol = 'VAPORES' and date > '2010-05-31';
+---------+----------+----------+------------+
| symbol | price | volume | date |
+---------+----------+----------+------------+
| VAPORES | 461.4900 | 1456466 | 2010-06-01 |
| VAPORES | 469.5200 | 2751787 | 2010-06-02 |
| VAPORES | 473.7700 | 2242733 | 2010-06-03 |
| VAPORES | 469.9500 | 1761573 | 2010-06-04 |
| VAPORES | 470.3400 | 2037112 | 2010-06-07 |
mysql> select a.*
from acciones a
inner join (
select symbol, max(price) as high
from acciones
group by symbol
) b on a.price = b.high and a.symbol = b.symbol;
+------------+------------+----------+------------+
| symbol | price | volume | date |
+------------+------------+----------+------------+
@ccarpenterg
ccarpenterg / customized.py
Created November 2, 2012 22:10
A Tornado decorator to display a customized UI for authenticated users.
def customized(default=None, template=None):
def decorator(method):
@functools.wraps(method)
def wrapper(self, *args, **kargs):
self.template = default
if self.current_user:
self.template = template
return method(self, *args, **kargs)
return wrapper
return decorator
@ccarpenterg
ccarpenterg / KY-counties-pop.csv
Last active December 14, 2015 20:19
Kentucky Population Map
id name population
21217 Taylor County 24512
21121 Knox County 31883
21071 Floyd County 39451
21125 Laurel County 58849
21035 Calloway County 37191
21107 Hopkins County 46920
21005 Anderson County 21421
21097 Harrison County 18846
21103 Henry County 15416
21217 Taylor County 24512
21121 Knox County 31883
21071 Floyd County 39451
21125 Laurel County 58849
21035 Calloway County 37191
21107 Hopkins County 46920
21005 Anderson County 21421
21097 Harrison County 18846
21103 Henry County 15416