Skip to content

Instantly share code, notes, and snippets.

View tbarbugli's full-sized avatar

Tommaso Barbugli tbarbugli

View GitHub Profile
@tbarbugli
tbarbugli / example_queries.cql
Created October 20, 2014 19:43
example_queries.cql
CREATE KEYSPACE videodb WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
use videodb;
// Basic entity table for a user
// Includes a LIST of email addresses
CREATE TABLE users (
username varchar,
firstname varchar,
lastname varchar,
{% if verb.infinitive = 'delete' %}
{{ actor.id }}-{{ time.strftime('%Y-%m-%d') }}
{% else %}
{{ verb.id }}_{{ time.strftime('%Y-%m-%d') }}
{% endif %}
@tbarbugli
tbarbugli / signer.rb
Created November 7, 2014 13:57
signer.rb
require 'openssl'
require 'base64'
module Stream
class Signer
@key = nil
def initialize(key)
@key = key.to_s
@sha1 = OpenSSL::Digest.new('sha1')

Build a scalable Twitter clone with Django and GetStream.io

In this tutorial we are going to build a Twitter clone using Django and GetStream.io, a hosted API for newsfeed development.

We will show you how easy is to power your newsfeeds with GetStream.io. For brevity we leave out some basic Django-specific code and recommend you refer you to the Github project for the complete runnable source code. At the end of this tutorial we will have a Django app with a profile feed, a timeline feed, support for following users, hashtags and mentions.

I assume that you are familiar with Django. If you're new to Django the [official tutorial] (https://docs.djangoproject.com/en/2.0/intro/) explains it very well.

def say_hi():
sudo('hostname')
sudo('sleep 3')
@roles('webservers')
@parallel
def trythis():
with settings(pool_size=3):
execute(say_hi)
@tbarbugli
tbarbugli / webhook_payload_example.json
Last active August 29, 2015 14:11
webhook_payload_example.json
# updates are sent in batches (up to 100 activities per push)
[
[{
"deleted":[],
"new":[{"actor":"1","verb":"tweet","object":"1","target":null,"time":"2014-12-15T17:20:37.258","foreign_id":null,"id":"af781804-847e-11e4-8080-80012fb97b9e","tweet":"Hello world"}],
"published_at":"2014-12-15T17:20:37.263518+00:00",
"feed":"user:2"}
],
[{
"deleted":["38f81366-847f-11e4-9c94-0cc47a024be0"],
@tbarbugli
tbarbugli / notification_only_model.py
Created December 18, 2014 11:01
store activities in notification feeds
class MyActivityModel(Activity):
@property
def activity_author_feed(self):
return 'notification'
follows = [
{:source => 'flat:1', :target => 'user:1'},
{:source => 'flat:1', :target => 'user:3'}
]
client.follow_many(follows)
@tbarbugli
tbarbugli / How to build a notification feed.md
Last active October 17, 2021 20:13 — forked from tschellenbach/notify_tut.md
How to build a notification feed using Stream

How to build a notification feed using Stream

Introduction

In this tutorial we are going to show how easy it is to build a notification feed using GetStream.io. First of all, let's quickly introduce you to our fictional example app. It's called bug-your-friends.com and allows you interact with your friends, ping them, follow them or poke them. Here's a quick list of example interactions:

  • poke another user (eg. Thierry pokes Alessandra)
  • follow a user (eg. Tommaso follows Iris)
  • ping a user (eg. Josie pings Carolina)

Whenever a user is part of one of these interactions, we want to update his notification feed, update the number of unseen and unread

@tbarbugli
tbarbugli / How to build a notification feed php.md
Last active August 29, 2015 14:16
How to build a notification feed using Stream

How to build a notification feed using Stream

Introduction

In this tutorial we are going to show how easy it is to build a notification feed using GetStream.io. First of all, let's quickly introduce you to our fictional example app. It's called bug-your-friends.com and allows you interact with your friends, ping them, follow them or poke them. Here's a quick list of example interactions:

  • poke another user (eg. Thierry pokes Alessandra)
  • follow a user (eg. Tommaso follows Iris)
  • ping a user (eg. Josie pings Carolina)

Whenever a user is part of one of these interactions, we want to update his notification feed, update the number of unseen and unread