Skip to content

Instantly share code, notes, and snippets.

View pbouzakis's full-sized avatar

Paul Bouzakis pbouzakis

View GitHub Profile
@pbouzakis
pbouzakis / gist:2352989
Created April 10, 2012 17:20
Documents
// super simple
// all you need is the relation key, since the rest of the hypermedia control info is instead the individual items self relation
{
"http://rel.nkstdy.co/document": [
{
"ean":"032cfa77face18c7ce5cdac190d34b202f4a0574eb6437427ab018b59495445c",
"title":"JS2",
"dateAdded":"2012-04-03T19:32:07.583Z",
"dateModified":"2012-04-05T17:22:10.796Z",
"use strict";
var Q = require("q");
var restify = require("restify");
module.exports = function (bnCloud) {
return function (serverRequest, serverResponse, next) {
var authHeaders = serverRequest.authorization;
var log = (serverRequest.log && serverRequest.log.trace.bind(serverRequest.log)) || console.log.bind(console);
var random = Math.floor(Math.random() * 100001);
var sha256 = crypto.createHmac("sha256", random + "TROGDOR_THE_BURNINATOR");
var timestamp = new Date().toJSON();
return sha256.update(customerId + deviceToken).digest("hex");
function itemMapper(parentCourse) {
return function (item) {
return new itemViewModel(item, parentCourse);
};
}
// later
var firstCourse = terms[0].courses[0];
// inside your object literal
include /mixins
section.reader(data-bind="event: { mousemove: revealNavigationButtons }")
// ko if: itemSrc
iframe#nere-frame(data-bind="attr: { src: itemSrc }", width="100%", height="100%", frameborder="0")
// /ko
+components("flag", "pages", "$data")
div(data-winning-region="navButtons")
form(data-bind="submit: signIn")
block content
+signInErrorMessage()
+signInInputs()
+signInSubmitButton()
// requirejs aka "AMD" module
define(["./utils", "./userService"], function (utils, userService) {
// everthing in here is my module
});
define(function (require) {
var utils = require("./utils");
@pbouzakis
pbouzakis / gist:8f771ae454faa6762e04
Last active August 29, 2015 14:04
Playing around with macro's using sweet.js. Here is an attempt at sweetening privacy with private maps.
/*
Sweet.js macros for privacy sugar.
Below could be rewritten using es6 weakmaps.
*/
macro privacy {
rule {} => {
var id = ++privates.id
var privMap = {}
this.__id = id
privates[id] = privMap
@pbouzakis
pbouzakis / gist:7efcfd06bcc9b4d98481
Created August 5, 2014 17:38
Monkey patching `applyBindingsToDescendants` to support insertion points.
ko.applyBindingsToDescendants = (function (original) {
return function (childBindingContext, element) {
var insertionNodes = ko.utils.domData.get(element, "insertionNodes");
original.apply(ko, arguments);
if (insertionNodes) {
transcludeInto(element, insertionNodes);
}
};
if (length >= 3 && isIndeterminate) {
isIndeterminate = false;
} else if (length > 0 && length < 3 && !isIndeterminate) {
that.hasError(true);
} else {
that.isQueryTextInvalid(true);
that.hasError(false);
}