Skip to content

Instantly share code, notes, and snippets.

View lennerd's full-sized avatar
🤓

Lennart Hildebrandt lennerd

🤓
View GitHub Profile
const components = {
'project.header': ProjectHeader,
'project.body': ProjectBody,
'project.footer': ProjectFooter,
};
components['project.header'] = CustomProjectHeader;
render(
<Provider components={components}>
@lennerd
lennerd / nunjucksify.js
Last active August 29, 2015 14:17
Browserify Transformer for Nunjucks Templates
var through = require('through'),
path = require('path'),
nunjucks = require('nunjucks'),
appRootPath = require('app-root-path').path,
_ = require('underscore');
var getTemplateReg = /env\.getTemplate\(("(.*?)")/g;
/**
* Calculates the templates path relative to the app root path.
@lennerd
lennerd / scope.js
Last active August 29, 2015 14:07
Simple library for dependency injection in Javascript. Heavily inspired by the Pimple library of Fabien Potencier.
/*!
* Copyright (c) 2014 Lennart Hildebrandt
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
@lennerd
lennerd / rccHack.ino
Last active August 29, 2015 14:03
Clean way to received signals from the RCC-controller on the Arduino
/*
MIT License
Copyright (c) 2014 Lennart Hildebrandt aka lennerd (https://github.com/lennerd)
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
@lennerd
lennerd / line_point_distance.pde
Created April 9, 2014 11:44
Line to Point Distance in Processing.
void setup() {
size(800, 600);
background(255);
noLoop();
}
void draw() {
line(50, 50, 750, 550);
}
@lennerd
lennerd / class.js
Last active December 13, 2015 22:29
A way to have classes in Javascript
// Orginial version from John Resig (http://ejohn.org/blog/simple-javascript-inheritance/)
(function(){
var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\b\__super\b/ : /.*/;
this.Class = function(){};
this.Class.create = function(prop) {
var super = this.prototype, name, prototype;
@lennerd
lennerd / object-hash.js
Created February 19, 2013 09:39
A way to hash JavaScript objects.
(function() {
var lastStorageId = 0;
this.Object.hash = function(object) {
var hash = object.__id;
if (hash === undefined)
hash = object.__id = lastStorageId++;
return '#' + hash;
@lennerd
lennerd / DoctrineParamConverter.php
Created April 5, 2012 13:54
Multiple ways of using the given request parameters for detecting the entity in the request attributes.
<?php
namespace Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ConfigurationInterface;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpFoundation\Request;
use Doctrine\Common\Persistence\ManagerRegistry;
/*