Skip to content

Instantly share code, notes, and snippets.

View tbarbugli's full-sized avatar

Tommaso Barbugli tbarbugli

View GitHub Profile
@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!

<script>
alert()
</script>
$digest = hash_hmac('sha1', $feed_id, sha1($key, true), true);;
return trim(strtr(base64_encode($value), '+/', '-_'), '=');
@tbarbugli
tbarbugli / activity_enrich.php
Last active August 29, 2015 14:07
activity_enrich
<?php
function get_users($ids){
// queries the db and returns an assoc array eg. array(1=>user1,...)
return array(
'1'=> 'tommaso',
'2'=> 'mike',
'3'=> 'thierry',
);
@tbarbugli
tbarbugli / autoload.php
Created October 8, 2014 07:17
autoload.php
function autoload($className)
{
$className = ltrim($className, '\\');
$fileName = '';
$namespace = '';
if ($lastNsPos = strrpos($className, '\\')) {
$namespace = substr($className, 0, $lastNsPos);
$className = substr($className, $lastNsPos + 1);
$fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
}
@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')
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"],