Skip to content

Instantly share code, notes, and snippets.

View faddai's full-sized avatar

Francis Addai faddai

View GitHub Profile
@faddai
faddai / app.js
Last active August 29, 2015 14:25 — forked from khash/app.js
Cloud 66 Status Page Source Code
Handlebars.registerHelper('equal', function(lvalue, rvalue, options) {
if (arguments.length < 3)
throw new Error("Handlebars Helper equal needs 2 parameters");
if( lvalue!=rvalue ) {
return options.inverse(this);
} else {
return options.fn(this);
}
});
@faddai
faddai / gist:4223224
Created December 6, 2012 09:28 — forked from inklesspen/gist:4222841
ACLs, context objects, and URL Dispatch in Pyramid
# A worked example based on http://docs.pylonsproject.org/projects/pyramid/en/1.3-branch/narr/urldispatch.html#using-pyramid-security-with-url-dispatch
# in your configuration section (typically in myapp/__init__.py)
config.add_route('articles.edit', 'article/{id}/edit', factory='myapp.acl.ArticleACL')
# in myapp/acl.py
class ArticleACL(object):
def __init__(self, request):
# First, we assume this ACL object is used only in routes that provide an article id; if need be, you can add some sanity checking here, or some if/else branching
@faddai
faddai / gist:3185713
Created July 27, 2012 01:41 — forked from remy/gist:350433
Storage polyfill
if (typeof window.localStorage == 'undefined' || typeof window.sessionStorage == 'undefined') (function () {
var Storage = function (type) {
function createCookie(name, value, days) {
var date, expires;
if (days) {
date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
expires = "; expires="+date.toGMTString();
@faddai
faddai / gpa_calculator.js
Created May 1, 2012 12:29 — forked from ranskills/gpa_calculator.js
GPA Calculator In JavaScript
var gradeLetters = ['a', 'b+', 'b', 'c+', 'c', 'd', 'f', 'af', 'wf'],
gradePoints = [4, 3.5, 3, 2.5, 2, 1, 0, 0, 0];
function getNumCoursesToBeEntered() {
"use strict";
var numCourses = 0,
input = "";
do {
input = prompt("Enter number of subjects?");