Skip to content

Instantly share code, notes, and snippets.

View edy's full-sized avatar

Eduard Baun edy

  • Paderborn, Germany
View GitHub Profile
@edy
edy / Rights.js
Created August 23, 2014 11:48 — forked from tarlepp/Rights.js
'use strict';
var _ = require('lodash');
var actionUtil = require('sails/lib/hooks/blueprints/actionUtil');
/**
* Service function which adds necessary object specified conditions to Project
* model queries. Workflow with this is following:
*
* 1) Fetch project ids where current user is attached to
'use strict';
var actionUtil = require('sails/lib/hooks/blueprints/actionUtil');
/**
* todo
*
* @param {Request} request Request object
* @param {Response} response Response object
* @param {Function} next Callback function

I am keeping this as a reference to balderdashy/sails#352

Working with SailsJS v0.10-rc5: I am trying to keep the magic of blueprint controllers while at the same time protecting some model attributes from being changed by users on the default routes. I.e.: prevent access to the is_admin attribute on regular CRUD routes and implement a promote action or something similar on the UserController which makes the neccessary checks.

In order to do this, I came up with the following policy in combination with a small addition to the model definitions:

// file: api/policies/protectedAttributes.js

/**

so you'd do something like:

var isAllowedTo = require('../api/policies/isAllowedTo');
module.exports = {
  UserController: {
    create: isAllowedTo('createUser')
  }
}
@edy
edy / JSONP.js
Last active December 19, 2015 14:59 — forked from icodeforlove/JSONP.js
/**
* simple JSONP support
*
* JSONP.get('https://api.github.com/gists/5973376', function (data) { console.log(data); });
* JSONP.get('https://api.github.com/gists/5973376', {}, function (data) { console.log(data); });
*
* gist: https://gist.github.com/edy/5973376
*/
var JSONP = (function (document) {
var requests = 0,
#!/bin/sh
# This program has two feature.
#
# 1. Create a disk image on RAM.
# 2. Mount that disk image.
#
# Usage:
# $0 <dir> <size>
#
#!/bin/bash
# http://blog.streak.com/2013/01/how-to-build-safari-extension.html
XAR=path/to/xar/bin
BUILD_DIR=path/to/dir/with/cert/files
EXTENSION=your extension name
$XAR -czf $EXTENSION.safariextz --distribution $EXTENSION.safariextension
$XAR --sign -f $EXTENSION.safariextz --digestinfo-to-sign digest.dat --sig-size `cat $BUILD_DIR/size.txt` --cert-loc $BUILD_DIR/cert.der --cert-loc $BUILD_DIR/cert01 --cert-loc $BUILD_DIR/cert02
openssl rsautl -sign -inkey $BUILD_DIR/key.pem -in digest.dat -out sig.dat
$XAR --inject-sig sig.dat -f $EXTENSION.safariextz