Skip to content

Instantly share code, notes, and snippets.

View wbashir's full-sized avatar

Warsame Bashir wbashir

View GitHub Profile
@wbashir
wbashir / gist:5984665
Created July 12, 2013 13:58
Sidr open menu on body load
<html>
<head>
<!-- Your stuff -->
<!-- Include Sidr bundled CSS theme -->
<link rel="stylesheet" href="stylesheets/jquery.sidr.dark.css">
</head>
<body onload="init()">
#!/bin/bash
# let's start fresh
rm -rf .demeteorized
rm /tmp/newfile
# run + cd
demeteorizer
cd .demeteorized
@wbashir
wbashir / gist:6152093
Created August 4, 2013 21:49
Remove S3 document when user is deleted
collection.find().observe({
removed: function (oldDoc) {
// delete oldDoc._id from S3
}
});
$(document).on("mouseenter", ".plot .label",
function (event) {
$(this).animate({ opacity: 0 },
function () {
$(this).addClass('hidden-label');
}
).delay(5000).animate({ opacity: 0.85 },
function () {
$(this).removeClass('hidden-label');
}
@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) {
)};
@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: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: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: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: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.
};