Skip to content

Instantly share code, notes, and snippets.

View tatiana's full-sized avatar

Tatiana Al-Chueyr tatiana

View GitHub Profile
@tatiana
tatiana / classic_billing_dag.py
Last active January 6, 2022 10:28
(A) Sample billing ETL pipeline
#!/usr/bin/env python
__author__ = "Kenten Danas"
from datetime import datetime
import pandas as pd
from airflow import DAG
from airflow.decorators import dag, task
from airflow.providers.snowflake.hooks.snowflake import SnowflakeHook
from airflow.providers.snowflake.transfers.s3_to_snowflake import S3ToSnowflakeOperator
@tatiana
tatiana / secure_websocket.py
Last active January 25, 2019 08:15
tornado websocket connection & cookie example
"""
Example of WebSocket receiving cookies from session.
# Currently using tornado==4.0.2
pip install git+http://github.com/tornadoweb/tornado.git
Run:
python secure_websocket.python
and access online:
@tatiana
tatiana / lex_user_descriptor
Created October 1, 2014 11:41
Example of user descriptor at Lex recommendation platform, at Globo.com
{
"http://globopedia.com/Combate": {
"seen": "explicit",
"frequency": 1,
"label": "Combate",
"last_seen": "20100000000000000"
},
"http://globopedia.com/DiegoBrandao": {
"seen": "explicit",
"frequency": 2,
@tatiana
tatiana / lex_user_history
Created October 1, 2014 11:28
Example of user activities generated by Lex recommendation platform, at Globo.com
[
{
"url": "http://ego.globo.com/beleza/noticia/2014/04/wanda-grandi-pratica-wakeboard-para-manter-boa-forma.html",
"timestamp": "20140425141131560",
"product": "ego"
},
{
"url": "http://ego.globo.com/beleza/noticia/2014/04/wanda-grandi-pratica-wakeboard-para-manter-boa-forma.html",
"timestamp": "20140425141430150",
"product": "ego"
@tatiana
tatiana / gcom_user_history_example
Created October 1, 2014 11:08
Example of user history retrieved from HBase using Globo.com Horizon
{
"ego": {
"20140925064926000": "http://ego.globo.com/noite/noticia/2014/09/clique-indiscreto-revela-intimidade-de-fani-pacheco-durante-evento-no-rio.html",
"20140910170414904": "http://ego.globo.com/famosos/noticia/2014/09/leilah-moreno-posa-nua-em-ensaio-sensual.html",
"20140910170320909": "http://ego.globo.com/famosos/noticia/2014/09/fred-volta-frequentar-igreja-evangelica.html",
"20140811131031865": "http://ego.globo.com/famosos/tudo-sobre/jessika-alves.html",
"20140811125325981": "http://ego.globo.com/beleza/noticia/2014/08/jessika-alves-mantem-forma-com-aulas-de-danca-saio-exausta.html",
"20140811125324910": "http://ego.globo.com/famosos/tudo-sobre/jessika-alves.html",
"20140811125317149": "http://ego.globo.com/famosos/noticia/2014/08/jessika-alves-abre-o-jogo-sobre-ensaio-nu-foi-muito-facil.html",
"20140808141034667": "http://ego.globo.com/famosos/tudo-sobre/carla-prata.html",
@tatiana
tatiana / fibonacci
Created June 18, 2014 15:22
Comparison of recursive and iterative implementations of Fibonacci number
"""
Example of how bad performance of recursive implementations can be when compared to iterative approaches.
For more in this topic, read Guido van Rossum (creator of Python programming language) blog post:
http://neopythonic.blogspot.com.br/2009/04/tail-recursion-elimination.html
"""
__author__ = "Tatiana Al-Chueyr <tatiana.alchueyr@gmail.com>"
@tatiana
tatiana / kafka_consumer.py
Last active August 29, 2015 14:02
Example of how to process kafka messages which are in Avro format
"""
Example of how to consume messages from Kafka, through Zookeeper.
Compatible with:
- Python 2.7.x
- Kafka 0.7.1
- Zookeeper 3.4.5
Requires the following Python packages, available at pypi.python.org:
fastavro==0.7.8
@tatiana
tatiana / simple_tornado_server.py
Created March 14, 2014 18:46
Sample Tornado server, both asynchronous and synchronous (blocking)
import time
from tornado import gen, httpclient
from tornado.ioloop import IOLoop
from tornado.httpserver import HTTPServer
from tornado.log import app_log
from tornado.options import define, options, parse_command_line
from tornado.web import asynchronous, Application, RequestHandler, URLSpec
DEBUG = True
@tatiana
tatiana / pyapi_setup.sh
Last active August 29, 2015 13:57
Setup of Python environment at Ubuntu 12.04 for PyAPI training
#!/bin/bash
# Script by @tatiana (Tatiana Al-Chueyr)
# Available at https://gist.github.com/tatiana/9543419
clear
echo "Installing git (Version control manager)"
sudo apt-get install git
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hi from Flask!"
if __name__ == "__main__":