Skip to content

Instantly share code, notes, and snippets.

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. 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/1.7/intro/install/) explains it very well.

Bootstrap the Django application

@vietlq
vietlq / How to build a notification feed.md
Created October 4, 2015 14:35 — forked from tbarbugli/How to build a notification feed.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

import os
from fabric.api import env, require, run, sudo, cd
env.project_name = ''
env.server_name = ''
env.webapps_root = '/opt/webapps/'
env.project_root = os.path.join(env.webapps_root, env.project_name)
env.activate_script = os.path.join(env.project_root, 'env/bin/activate')
env.wsgi_file = os.path.join(env.project_root, 'django.wsgi')
@vietlq
vietlq / subprocess_timeout.py
Created May 14, 2012 12:46 — forked from kirpit/bash.py
Enables to run subprocess commands in a different thread with TIMEOUT option!
class Command(object):
'''
Enables to run subprocess commands in a different thread
with TIMEOUT option!
Based on jcollado's solution:
http://stackoverflow.com/questions/1191374/subprocess-with-timeout/4825933#4825933
'''
def __init__(self, cmd):
self.cmd = cmd
# The latest version of this script is now available at
# https://github.com/jasoncodes/dotfiles/blob/master/aliases/rbenv.sh
VERSION=1.9.3-p286
brew update
brew install rbenv ruby-build rbenv-vars readline ctags
if [ -n "${ZSH_VERSION:-}" ]; then
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.zshrc
else
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.bash_profile

Keybase proof

I hereby claim:

  • I am vietlq on github.
  • I am vietlq (https://keybase.io/vietlq) on keybase.
  • I have a public key whose fingerprint is E6C9 B812 DD28 F53F DC23 496E 662E 0FF5 B2DB 6E92

To claim this, I am signing this object:

@vietlq
vietlq / stream_to_youtube.sh
Created September 3, 2016 13:30 — forked from olasd/stream_to_youtube.sh
Stream video to youtube via ffmpeg
#! /bin/bash
#
# Diffusion youtube avec ffmpeg
# Configurer youtube avec une résolution 720p. La vidéo n'est pas scalée.
VBR="2500k" # Bitrate de la vidéo en sortie
FPS="30" # FPS de la vidéo en sortie
QUAL="medium" # Preset de qualité FFMPEG
YOUTUBE_URL="rtmp://a.rtmp.youtube.com/live2" # URL de base RTMP youtube
@vietlq
vietlq / sw.js
Created September 10, 2016 15:01 — forked from voduytuan/sw.js
importScripts('js/sw-toolbox.js');
toolbox.options.debug = false;
toolbox.precache(['/']);
//FOr homepage, we use fastest so that it update new content for next request
toolbox.router.get('/', toolbox.fastest);
// The route for the images
@vietlq
vietlq / SchemaSpy-HOWTO.md
Created September 16, 2016 10:03 — forked from dpapathanasiou/SchemaSpy-HOWTO.md
How to use SchemaSpy to generate the db schema diagram for a PostgreSQL database

SchemaSpy is a neat tool to produce visual diagrams for most relational databases.

Here's how to use it to generate schema relationship diagrams for PostgreSQL databases:

  1. Download the jar file from here (the current version is schemaSpy_5.0.0.jar)

  2. Get the PostgreSQL JDBC driver (either the JDBC3 or JDBC4 jar file is fine)

  3. Run the command against an existing database. For most databases, the schema (-s option) we are interested in is the public one:

@vietlq
vietlq / kernel.js
Created September 22, 2016 18:07 — forked from Carreau/kernel.js
A node.js kernel for IPython notebook. You can see the explanation of the ipynb rendered in http://nbviewer.ipython.org
zmq = require("zmq")
fs = require("fs")
var config = JSON.parse(fs.readFileSync(process.argv[2]))
var connexion = "tcp://"+config.ip+":"
var shell_conn = connexion+config.shell_port
var pub_conn = connexion+config.iopub_port
var hb_conn = connexion+config.hb_port