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 / ep.json
Created March 14, 2012 16:18
Ein DDI-Plugin für Etherpad Lite
{
"parts": [
{
"name": "ddi-plugin",
"hooks": {
"expressCreateServer": "ep_ddi/plugin:expressServer"
}
}
]
}
@edy
edy / post-receive.sh
Last active October 9, 2015 08:07
post receive hook for git
#!/bin/bash
postreceivescript=$(git config hooks.postreceivescript)
redmineid=$(git config hooks.redmineid)
url=$(git config hooks.url)
while read msg; do
echo "Sending post-receive email"
echo "$msg" | /usr/share/doc/git-core/contrib/hooks/post-receive-email
#!/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
#!/bin/sh
# This program has two feature.
#
# 1. Create a disk image on RAM.
# 2. Mount that disk image.
#
# Usage:
# $0 <dir> <size>
#
@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,
@edy
edy / angular-directive-navmenu.js
Last active May 30, 2018 04:16
AngularJS directive to mark navigation menu items as active
'use strict';
// <ul nav-menu="active">
// <li><a href="/one">Page One</a></li>
// <li><a href="/two">Page Two</a></li>
// <li><a href="/three">Page Three</a></li>
// </ul>
app.directive('navMenu', function($location) {
return function(scope, element, attrs) {

so you'd do something like:

var isAllowedTo = require('../api/policies/isAllowedTo');
module.exports = {
  UserController: {
    create: isAllowedTo('createUser')
  }
}

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

/**

'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
@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