Skip to content

Instantly share code, notes, and snippets.

View tbarbugli's full-sized avatar

Tommaso Barbugli tbarbugli

View GitHub Profile
@tbarbugli
tbarbugli / reset.sql
Created May 1, 2013 13:10
reset all sequences on a postgres db
SELECT 'SELECT SETVAL(' ||quote_literal(S.relname)|| ', MAX(' ||quote_ident(C.attname)|| ') ) FROM ' ||quote_ident(T.relname)|| ';'
FROM pg_class AS S, pg_depend AS D, pg_class AS T, pg_attribute AS C
WHERE S.relkind = 'S'
AND S.oid = D.objid
AND D.refobjid = T.oid
AND D.refobjid = C.attrelid
AND D.refobjsubid = C.attnum
ORDER BY S.relname;
@tbarbugli
tbarbugli / video_example.css
Last active August 11, 2023 14:27
CSS example for video layout
#root {
background:linear-gradient(90deg, Red, Orange, Yellow, Green, Blue, Indigo,violet);
}
.str-video__video-placeholder {}
.str-video__participant-details {}
.str-video__participant-details__name {}
@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

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.

{
"openapi": "3.0.0",
"info": {
"description": "Stream Analytics API",
"version": "1.0.0",
"title": "Stream Analytics",
"contact": {
"email": "support@getstream.io"
}
},
@tbarbugli
tbarbugli / s3botostorage.py
Created July 25, 2012 21:51
S3BotoStorage
from boto.utils import parse_ts
from django.core.files.storage import get_storage_class
from storages.backends.s3boto import S3BotoStorage
"""
make sure you have this setting
AWS_PRELOAD_METADATA = True
and that you have python-dateutils==1.5 installed
"""
This file has been truncated, but you can view the full file.
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("React"));
else if(typeof define === 'function' && define.amd)
define(["React"], factory);
else {
var a = typeof exports === 'object' ? factory(require("React")) : factory(root["React"]);
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
}
})(window, function(__WEBPACK_EXTERNAL_MODULE_react__) {
import stream
client = stream.connect(api_key, api_secret)
feed = client.feed('user', 'raji')
activity_adds = [a for a in feed.get(limit=100)['results'] if a['verb'] == 'add']

Keybase proof

I hereby claim:

  • I am tbarbugli on github.
  • I am tbarbugli (https://keybase.io/tbarbugli) on keybase.
  • I have a public key ASCmbtrXl-iWwYw0cN6pWX2vSq32qtDbRENwxD0h5m5LkQo

To claim this, I am signing this object:

import random
random.seed(1)
l = []
for i in range(1, 10000):
r = random.randint(1, 1000)
append_sorted(l, r)
print(l)