Skip to content

Instantly share code, notes, and snippets.

View tbarbugli's full-sized avatar

Tommaso Barbugli tbarbugli

View GitHub Profile
@tbarbugli
tbarbugli / create_stream_jwt.js
Created March 2, 2016 14:25
create_stream_jwt.js
var streamSigner = require('getstream/src/lib/signing');
var api_key = 'AAABBBCCCDDD';
streamSigner.JWTScopeToken(api_key, 'feed', '*', {'feedId': '*'});
from cassandra.policies import DCAwareRoundRobinPolicy
from cassandra.policies import HostDistance
from IPy import IP
class LocalNetworkDCAwareRoundRobinPolicy(DCAwareRoundRobinPolicy):
def distance(self, host):
host_distance = super(LocalNetworkDCAwareRoundRobinPolicy, self).distance(host)
if IP(host.address).iptype() == 'PUBLIC':
def get_class_by_slug(slug):
def get_subclasses(cls):
yield cls
if cls.__subclasses__():
for sub in cls.__subclasses__():
for s in get_subclasses(sub):
yield s
components = {cls.slug: cls for cls in get_subclasses(BaseClass)}
return components[slug]
#!/bin/bash
METADATA_URL_BASE="http://169.254.169.254/2012-01-12"
apt-get update
apt-get install mdadm curl --yes
# Configure Raid - take into account xvdb or sdb
root_drive=`df -h | grep -v grep | awk 'NR==2{print $1}'`
if [ "$root_drive" == "/dev/xvda1" ]; then
@tbarbugli
tbarbugli / client.clj
Created October 14, 2015 21:23
Steram Cloujure API client
(ns fub.timeline.stream
(:require [clojure.string :as strs]
[clojure.data.codec.base64 :as b64]
[full.core.sugar :refer :all]
[full.async :refer :all]
[full.core.config :refer [opt]]
[full.http.client :as http]
[full.core.log :as log]
[full.time :refer [dt<-iso-ts dt->iso-ts]]
[full.json :refer [write-json]])
@tbarbugli
tbarbugli / deco.py
Last active September 21, 2015 16:28
@my_deco
def myfn():
'''
doc string...
'''
pass
myfn.__name__
@tbarbugli
tbarbugli / deco.py
Last active September 16, 2015 18:25
def deco(fn):
def wrap():
pass
return fn()
return wrap
@deco
def my_fn():
'''
does something
@tbarbugli
tbarbugli / unsubscribe.js
Created September 16, 2015 15:31
unsubscribe.js
user1 = client.feed('user', '1', 'feedtoken');
subscription = user1.subscribe(callbackFn);
// cancel the subscription for user1 feed
subscription.cancel();
@tbarbugli
tbarbugli / api_client_update.md
Last active August 28, 2015 20:01
Stream call for API client update

Please update your API client

Introduction

Hello everyone, over the last months we made substantial infrastructure improvements to speed-up response time and make our APIs even more rock solid than before.

Most of these improvements became generally available transparently, unfortunately there are a few changes ready to go live soon that are not supported by our old API clients.

We strongly suggest you to upgrade your clients to the latest version available or at least make sure that your apps run on a recent version of the API client. In order to simplify this, we made a simple table with the clients and frameworks integrations. If the version of your client is listed in this table, you can stop reading this article and go back to building awesome stuff!

def activity_notify
[feed_manager.get_feed('flat', 'global')]
end