Skip to content

Instantly share code, notes, and snippets.

View wbashir's full-sized avatar

Warsame Bashir wbashir

View GitHub Profile
function setPresence (whereAt) {
Meteor.Presence.state = function() {
return {
online : true,
whereAt: whereAt
}
}
}
function trackPageview (path) {
# coding=UTF-8
from __future__ import division
import re
# This is a naive text summarization algorithm
# Created by Shlomi Babluki
# April, 2013
class SummaryTool(object):
@wbashir
wbashir / gist:6416909
Created September 2, 2013 20:18
Template 'layout' is set as the default layout at the Router configure level.
<template name="layout">
{{yield 'header'}}
{{yield 'base'}}
<div class="content" id="content">
<div id="main-content">
{{yield 'mainContent'}}
@wbashir
wbashir / gist:6408451
Created September 2, 2013 01:20
Callback - Meteor update
Meteor.users.update({ _id: userID}, {
$set: {
createdAt: new Date()
}
}, false, true, function(err, result){
if(err)
console.log(err);
});
@wbashir
wbashir / gist:6408003
Created September 1, 2013 23:30
Controller - Extend so user is/isn't authorized with reactive computation.
MyController = RouteController.extend({
before: function () {
var onReady = function () {
if (/* whatever */)
this.render();
};
var onWait = function () {
// maybe show a loading or logging in function.
};
@wbashir
wbashir / gist:6401718
Created September 1, 2013 01:18
Base64 HMAC Encoding
def create_token():
message = bytes("Message")
secret = bytes("secret")
signature = base64.b64encode(hmac.new(secret, message, digestmod=hashlib.sha256).digest());
print(signature)
@wbashir
wbashir / gist:6399123
Created August 31, 2013 15:59
Scroll - Top IronRouter
Deps.autorun(function () {
var current = Router.current();
Deps.afterFlush(function () {
$('.content-inner').scrollTop(0);
$(window).scrollTop(0);
});
});
@wbashir
wbashir / gist:6381117
Created August 29, 2013 17:42
Before filter - Log in
this.route('/', {
before: function() {
if(!Meteor.loggingIn() && !Meteor.user()) {
this.redirect("login");
}
}
});
@wbashir
wbashir / gist:6373689
Created August 29, 2013 02:37
Refund Amount
/**
*
* @param chargeId
*/
refundChargeById: function (chargeId) {
var amount = 300; // this causes an undefined params error even though the underlying method doesn't expect {}
stripe.charges.refund(chargeId, amount,
function (err, refund) {
@wbashir
wbashir / gist:6372823
Created August 28, 2013 23:54
Stripe charge refund
var amount = Math.abs(invoice.total);
stripe.charges.refund(charge.data[0].id, amount,
function (err, refund) {
)};