Skip to content

Instantly share code, notes, and snippets.

@ipeluffo
ipeluffo / faust-views.py
Created July 1, 2019 23:12
Tweets hashtags real-time processing with Faust - Views
@app.page('/{hashtag}/count')
@app.table_route(table=hashtags_counts_table, match_info='hashtag')
async def hashtag_count(self, request, hashtag):
return self.json({
'hashtag': hashtag,
'count': hashtags_counts_table[hashtag],
})
@app.page('/hashtags')
@ipeluffo
ipeluffo / agent.py
Created July 1, 2019 23:00
Tweets hashtags real-time processing with Faust - Agent
hashtags_topic = app.topic('hashtags', value_type=str)
hashtags_counts_table = app.Table('hashtags_counts', default=int)
@app.agent(hashtags_topic)
async def hashtags_counter(hashtags) -> None:
async for hashtag in hashtags: # type: str
hashtags_counts_table[hashtag] += 1
@ipeluffo
ipeluffo / command.py
Last active July 1, 2019 23:01
Tweets hashtags real-time processing with Faust - Command
@app.command(option("--track", type=str, help="List of words in CSV format to filter stream of tweets", required=True))
async def hashtags_events_generator(self, track: str):
"""
Generate Kafka events for each hashtag found in tweets matching with the track used to filter the stream.
"""
logger.info(f"Searching tweets with hashtags: {track}")
client = _get_twitter_client()
req = client.stream.statuses.filter.post(track=track)
@ipeluffo
ipeluffo / docker-reference.md
Last active May 28, 2019 09:01
Docker commands reference

Docker cheat sheet

List all running and stopped containers

docker ps -a

List all running containers (just stating the obvious and also example use of -f filtering option)

docker ps -a -f status=running
@ipeluffo
ipeluffo / iris_parallel_coordinates.pde
Created December 5, 2015 15:59
Exercise to visualize Iris dataset using Processing (https://www.processing.org/)
int w = 1000;
int h = 600;
void setup() {
size(1000, 600);
background(0);
stroke(255);
float[] linesX = {};
@ipeluffo
ipeluffo / index.html
Last active November 14, 2015 15:29
Visualizations of Argentina's population
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<script type='text/javascript' src='https://public.tableau.com/javascripts/api/viz_v1.js'></script><div class='tableauPlaceholder' style='width: 982px; height: 742px;'><noscript><a href='#'><img alt='Dashboard 1 ' src='https:&#47;&#47;public.tableau.com&#47;static&#47;images&#47;Ma&#47;MapaPoblacinArgentina&#47;Dashboard1&#47;1_rss.png' style='border: none' /></a></noscript><object class='tableauViz' width='982' height='742' style='display:none;'><param name='host_url' value='https%3A%2F%2Fpublic.tableau.com%2F' /> <param name='site_root' value='' /><param name='name' value='MapaPoblacinArgentina&#47;Dashboard1' /><param name='tabs' value='no' /><param name='toolbar' value='yes' /><param name='static_image' value='https:&#47;&#47;public.tableau.com&#47;static&#47;images&#47;Ma&#47;MapaPoblacinArgentina&#47;Dashboard1&#47;1.png' /> <param name='animate_transition' value='yes' /><param name='display_static_image' va
@ipeluffo
ipeluffo / gitReference.md
Last active July 8, 2019 15:24
Git simple reference

Personal Git simple reference

Actions

List branches

git branch

List all branches (including remote branches)

Keybase proof

I hereby claim:

  • I am ipeluffo on github.
  • I am ipeluffo (https://keybase.io/ipeluffo) on keybase.
  • I have a public key whose fingerprint is 3D90 BDA6 6D96 7456 A602 7AC4 D50C 0771 B051 97C3

To claim this, I am signing this object: