Skip to content

Instantly share code, notes, and snippets.

View matthisk's full-sized avatar

Matthisk Heimensen matthisk

View GitHub Profile
@matthisk
matthisk / stream-js-activity-copy-limit.js
Created October 28, 2015 15:08
Stream JS example: Activity copy limit
// Don't copy over history
user1.follow('user', '2', { limit: 0 });
// Copy over a maximum of 300 activities
user1.follow('user', '3', { limit: 300 });
@matthisk
matthisk / stream-js-expire-tokens.js
Created October 28, 2015 15:22
Stream JS example: Expire tokens
var client = stream.connect('API_KEY', 'API_SECRET', 'APP_ID', { expireTokens: true });
@matthisk
matthisk / stream-js-promises.js
Last active October 28, 2015 16:25
stream-js example: Promises
var client = stream.connect('API_KEY', 'API_SECRET'),
user1 = client.feed('user','1');
user1.follow('user', '2')
.then(function(body) {
return user1.get({ limit: 1 });
})
.then(function(body) {
console.log(body);
})
@matthisk
matthisk / stream-js-follow-many.js
Last active October 28, 2015 16:25
Stream JS example: Follow many
var follows = [
{'source': 'flat:1', 'target': 'user:1'},
{'source': 'flat:1', 'target': 'user:2'},
{'source': 'flat:1', 'target': 'user:3'}
];
client.followMany(follows)
.then(function(body) { /* fulfillment handler */ })
.catch(function(error) { /* rejection handler */ });
@matthisk
matthisk / stream-js-add-to-many.js
Last active October 28, 2015 16:25
Stream JS example: Add to many
var activity = {'actor': 'User:1', 'verb': 'tweet', 'object': 'Tweet:1'};
var feeds = ['flat:1','flat:2','aggregated:3'];
client.addToMany(activity, feeds)
.then(function(body) { /* fulfillment handler */ })
.catch(function(error) { /* rejection handler */ });
@matthisk
matthisk / settings.json
Created December 11, 2015 16:26
stream-meteor settings.json
{
"streamApiSecret": "",
"public" : {
"streamApiKey": "",
"streamApiAppId": ""
}
}
@matthisk
matthisk / users.js
Last active December 14, 2015 08:59
stream-meteor follow yourself
// New users news feed follow his own user feed
Stream.feedManager.followUser(user._id, user._id);
@matthisk
matthisk / loc.js
Created December 14, 2015 09:22
Stream-meteor, fix geolocation addActivity in browser
if (! this.isSimulation && loc && loc.coords)
activity.place = getLocationPlace(loc);
@matthisk
matthisk / subscriptions.js
Created December 14, 2015 09:31
Stream-meteor subscriptions
// Global subscriptions
if (Meteor.isClient) {
Meteor.subscribe('news');
Meteor.subscribe('bookmarkCounts');
feedSubscription = Meteor.subscribe('Stream.feeds.flat');
}
@matthisk
matthisk / handlebars.js
Created December 14, 2015 10:05
equals operator
Handlebars.registerHelper('equals', function(a1, a2) {
return a1 === a2;
});