Skip to content

Instantly share code, notes, and snippets.

View cerivera's full-sized avatar

Carlos Rivera cerivera

View GitHub Profile
# example 1
some_class.some_method(some_paramater1,
some_parameter2,
some_parameter3)
# example 2
some_class.some_method(
some_parameter1,
some_parameter2,
@cerivera
cerivera / agg_test.md
Created August 26, 2015 13:07
Group Bys not behaving properly
> select * from steps where time > '2005-01-01 12:00:00' and time < '2005-01-02 12:00:00'
name: steps
-----------
time			user_id		value
2005-01-01T12:15:00Z	1234567890	48
2005-01-01T12:30:00Z	1234567890	9
2005-01-01T12:45:00Z	1234567890	31
2005-01-01T13:00:00Z	1234567890	44
2005-01-01T13:15:00Z	1234567890	26
@cerivera
cerivera / xml_build_tests.py
Created October 22, 2014 02:43
Testing an XML request with custom attributes (required)
def _uglify_xml(xml_output):
ugly = xml_output.replace(" ", "").replace("\n", "")
return ugly
def test_xml_basic_building():
d = {
'EAI': '11111111',
'DBHost': 'BISTEST',
'ReferenceId': 'user12345',
@cerivera
cerivera / xml_build_tests.py
Created October 22, 2014 02:42
test generating a real XML request
def test_xml_basic_building():
d = {
'EAI': '11111111',
'DBHost': 'BISTEST',
'ReferenceId': 'user12345',
'Request xmlns="http://www.example.com/WebDelivery" version="1.0"': {
'Products': {
'PremierProfile': {
'Subscriber': {
'OpInitials': 'CR',
@cerivera
cerivera / gist:bf567dedd80a46050c08
Created August 25, 2014 19:21
Failed upgrade with existing Alembic
INFO [alembic.migration] Context impl PostgresqlImpl.
INFO [alembic.migration] Will assume transactional DDL.
INFO [alembic.migration] Running upgrade None -> 1d8e4022d63b
Traceback (most recent call last):
File "/usr/local/bin/alembic", line 9, in <module>
load_entry_point('alembic==0.3.7dev', 'console_scripts', 'alembic')()
File "/usr/local/lib/python2.7/dist-packages/alembic-0.3.7dev-py2.7.egg/alembic/config.py", line 229, in main
**dict((k, getattr(options, k)) for k in kwarg)
File "/usr/local/lib/python2.7/dist-packages/alembic-0.3.7dev-py2.7.egg/alembic/command.py", line 121, in upgrade
script.run_env()
@cerivera
cerivera / gist:5c01f8f2e0f2b282472e
Created August 25, 2014 19:19
Enable TextClause values for server_default
# Test Models.py
class Test(Base):
__tablename__ = 'test'
id = Column(BigInteger, primary_key=True)
created_at = Column(DateTime, server_default=text('now()'))
created_at2 = Column(DateTime, server_default=text("(now() at time zone 'utc')"))
created_at3 = Column(DateTime, server_default=func.now())
###
python manage.py db downgrade
python manage.py db migrate -m "new migration scriptz"
python manage.py db upgrade
@cerivera
cerivera / foreach vs for loop
Last active April 6, 2017 14:14
Underscore.js foreach vs native for loop speed test
// Build 100000 alphabet dictionaries
var dict = {};
for (var i = 0; i < 100000; i++) {
dict[i] = {};
for (var c = 65; c < 65+26; c++) {
dict[i][String.fromCharCode(c)] = c;
}
}
// Loop through parent and child dictionaries in native JS
@cerivera
cerivera / functions.php
Created October 10, 2012 15:41
functions.php
<?php
/*
Author: Eddie Machado
URL: htp://themble.com/bones/
This is where you can drop your custom functions or
just edit things like thumbnail sizes, header images,
sidebars, comments, ect.
*/