Skip to content

Instantly share code, notes, and snippets.

View matthisk's full-sized avatar

Matthisk Heimensen matthisk

View GitHub Profile
from functools import partial
def some_view(request):
line_chart = LineChart()
render(request, 'template.html', {
'line_chart_as_html_200': partial(line_chart.as_html, line_chart, '200'),
})
$('button').on('click', function(e) {
var self = this;
e.preventDefault();
user.get({
limit: 1,
'mark_read': [$(this).attr('group')],
}).then(function(results) {
window.location = $(self).attr('href');
});
@matthisk
matthisk / notification-delete.js
Last active June 22, 2016 09:04
Reproducing an issue with the Notification feed
var stream = require('getstream');
var client = stream.connect('API_KEY', 'API_SECRET');
var feed = client.feed('notification', 'bandsintown-' + Date.now());
function errorHandler(error) {
console.error('Error: ', error['error']);
}
HomeController = RouteController.extend({
onBeforeAction: function () {
this.feedSubscription = feedSubscription;
}
});
@matthisk
matthisk / home.js
Last active December 14, 2015 13:49
activities: function() {
return Stream.feeds.flat.find({}, {sort: {time: -1}, limit: 3});
},
Template.cook.helpers({
firstName: function() {
return this.userName.split(' ')[0];
},
recipeTitle: function() {
return RecipesData[this.recipeName].title;
},
path: function() {
return Router.path('recipe', { name: this.recipeName },
{ query: { activityId: this._id } })
<template name="cook">
<a href="{{path}}" class="item-activity">
<span class="attribution">
<span class="avatar">
<img src="{{userAvatar}}" class="image-avatar">
</span>
<span class="meta">
<span class="author">{{firstName}}</span> made <span class="recipe">{{recipeTitle}}</span>: {{text}}
{{#if place}}<span class="location">&mdash;{{place}}</span>{{/if}}
<template name="activity">
{{#if equals this.verb 'cook'}}
{{> cook object}}
{{/if}}
{{#if equals this.verb 'bookmark'}}
{{> bookmark}}
{{/if}}
</template>
if (! this.isSimulation && loc && loc.coords)
activity.place = getLocationPlace(loc);
<template name="activity">
{{#with object}}
<a href="{{path}}" class="item-activity">
<span class="attribution">
<span class="avatar">
<img src="{{userAvatar}}" class="image-avatar">
</span>
<span class="meta">
<span class="author">{{firstName}}</span> made <span class="recipe">{{recipeTitle}}</span>: {{text}}