Skip to content

Instantly share code, notes, and snippets.

View kristianmandrup's full-sized avatar

Kristian Mandrup kristianmandrup

  • Freelancer
  • Copenhagen
View GitHub Profile
@kristianmandrup
kristianmandrup / Angular-packages.js
Created November 23, 2013 09:11
Angular.js plugins by category
// Forms
"forms-angular-bower": "0.0.27",
"angular-elastic": "~2.1.0",
"angular-rangeslider": "~0.0.1",
"angular-slider": "~0.1.6",
"angular-ui-select2", "~0.0.2"
"angular-ui-slider": "latest",
"angular-chosen": "~0.1.2",
"angular-date-range-picker", "~0.1.9",
"angular-contenteditable": "0.3.5",
@kristianmandrup
kristianmandrup / ability.coffee
Last active December 28, 2015 14:39
Authorize framework, a better design than CanCan (I think)
_ = require 'lodash'
# Always one Ability per User
module.exports = class Ability
constructor: (user) ->
@user = user
accessObj: (access) ->
_.extend(access, user)
Folder structure of app
app
models
decorators
- typically used to decorate a model with client side functionality
validators
- for validate middleware, one per model
routes
@kristianmandrup
kristianmandrup / project-generator
Created November 17, 2013 15:48
Project generator
https://github.com/Nami-Doc/brunch-with-ketchup
What's in the box
Angular.JS
JADE (as default templating)
CoffeeScript/LiveScript (-with skeletons in CS-)
Twitter Bootstrap 2.3 (Inspired by Angular-Brunch-Seed)
Bootswatch themes
Generators:
@kristianmandrup
kristianmandrup / auto-namespacing files.txt
Created November 17, 2013 14:41
Recipe for how to auto-generate namespaced modules in a web framework ;)
models/loader.ls
loads all files under models dir into app.Models namespace
models/validators/loader.ls
loads all files under validators dir into app.Model.Validator namespace
routes/validators/loader.ls
@kristianmandrup
kristianmandrup / namespace.js
Last active December 28, 2015 14:09
Namespaces for Coffee or LiveScript
namespaces.js
exports.do =
Models: {}
Controllers: {}
App = require \app\namespaces
# or even just
@kristianmandrup
kristianmandrup / gist:7372816
Last active December 27, 2015 18:49
Sketching out ideas for the next generation web framework

The next gen web framework

Tower.js

Uses Coffeescript all over, and with classes etc. Much closer to a full Rails implementation in Node.js

Still too much old school MVC, but has some support for sockets. Also has nice Authentication integration. Still lacks Authorization it seems. I should work on BeerCan again and finish it ;)

// Use fx to check if username is already taken
query = model.query ( collectionName, databaseQuery )
results = query.get ( )
// For validation use LGTM validator!!!
https://github.com/square/lgtm
http://corner.squareup.com/2013/08/lgtm-a-validation-library-for-javascript.html
https://github.com/square/lgtm/wiki
@kristianmandrup
kristianmandrup / cool_json_serializer.js
Created November 6, 2013 19:18
JSON serializer to exclude certain data or include extra data, using blueprints. Experimental POC ;)
var SerializeBlueprint = function() {
include: function(obj) {
return {};
},
exclude: function(obj, key, val) {
return false;
}
}
var Serializer = function(blueprint)
@kristianmandrup
kristianmandrup / angular-racer-data-security-policies
Last active December 27, 2015 14:39
Angular - Racer, basic security policies
var mwRunner = (args) ->
@index = 0;
# http://lostechies.com/chrismissal/2012/10/05/extending-objects-in-underscore/
_.extend @, args
@collection = @model.pluralize
@middlewares = []
# setup function to run if all middleware is passed through
@doneFun = args.last if args.last typeof Function