Skip to content

Instantly share code, notes, and snippets.

View tbarbugli's full-sized avatar

Tommaso Barbugli tbarbugli

View GitHub Profile
%matplotlib inline
import scipy as sp
import numpy as np
import matplotlib.pylab as plt
def error(f, x, y):
return sp.sum((f(x) - y)**2)
x = np.linspace(-np.pi, 1+np.pi, 201)
plt.plot(x, np.sin(x))
{{ object }}_{{ time.strftime("%Y-%m-%d") }}_{{ time.strftime('%H')|int // 2 }}
from stream_django.activity import create_reference
user_feed = feed_manager.get_user_feed(user.id)
activity = {
'actor': create_reference(user),
'verb': 'like',
'object': create_reference(liked_item),
'foreign_id': create_reference(liked_item)
}
@tbarbugli
tbarbugli / simplequeue.py
Created June 3, 2015 07:47
simplequeue.py
from celery.app import app_or_default
app = app_or_default()
connection = app.connection()
queue = connection.SimpleQueue('queue')
from stream_django import feed_manager
Rating.__bases__ = (Activity,) + Rating.__bases__
feed_manager.bind_model(Rating)
<?php
// Get curl version array
$version = curl_version();
// These are the bitfields that can be used
// to check for features in the curl build
$bitfields = Array(
'CURL_VERSION_IPV6',
'CURL_VERSION_KERBEROS4',
'CURL_VERSION_SSL',
@tbarbugli
tbarbugli / test_resolve.php
Last active August 29, 2015 14:18
test_resolve.php
<?php
$c = curl_init('https://us-east-api.getstream.io');
// force curl to try IPv4 first
curl_setopt($c, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
curl_exec($c);
echo curl_getinfo($c, CURLINFO_NAMELOOKUP_TIME);
?>
Configure an instance for your project
--------------------------------------
```js
var client = new StreamAnalytics({
projectId: "YOUR_PROJECT_ID",
writeKey: "YOUR_WRITE_KEY"
});
```
User centered metrics
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>io.stream.example</groupId>
<artifactId>example</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencyManagement>
@tbarbugli
tbarbugli / tracking_example.js
Last active August 29, 2015 14:17
tracking_example.js
// Configure an instance for your project
var client = new StreamAnalytics({
projectId: "YOUR_PROJECT_ID",
writeKey: "YOUR_WRITE_KEY"
});
// Track impressions (eg. messages in the http://stocktwits.com/symbol/ING page)
// Every activity (eg. messages) shown to the user should be tracked as an impression
var impression = {
viewerId: 'user:Thierry',