Skip to content

Instantly share code, notes, and snippets.

View TorbenKoehn's full-sized avatar

Torben Köhn TorbenKoehn

View GitHub Profile
<?php
declare(strict_types=1);
namespace Ion\Http\Middleware;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
class Queue extends \SplQueue
{
<?php
use Psr\Http\Message\ResponseInterface;
use Ion\Http;
use Ion\Http\{
MiddlewareInterface,
Middleware\Dispatcher,
Middleware\RunFilterTrait,
Response
};
@TorbenKoehn
TorbenKoehn / CustomRenderer.php
Last active April 8, 2016 08:35
Tale Jade custom renderer with Twig-like getters/setters
<?php
class ViewBag
{
private $subject;
public function __construct($subject)
{
<?php
//Methode 1
class Db
{
private $_timeOut = 30;
private $_cache = null;
//...
<?php
//Methode 1
class Model
{
protected $tableName = '';
//Default inflection im ctor?
}
<?php
return [
'db' => [
'host' => 'localhost',
'user' => '<db_user>',
'password' => '<db_password>',
'name' => '<database_name>'
]
];
@TorbenKoehn
TorbenKoehn / StringUtil.php
Created August 27, 2015 14:30
StringUtil class of the Tale Framework. Standalone. Provides useful string utilities and ruby-style string inflections for PHP
<?php
/**
* Tale\StringUtil - The Tale Framework
*
* @version 1.0
* @status Beta
* @author Torben Köhn <t.koehn@outlook.com>
*
* This software is distributed under the MIT license.
* A copy of the license has been distributed with this software.
namespace OwnScript.MyNamespace
use OwnScript.SomeOtherNamespace //kein * nötig, da OwnScript keine Klasse, sondern ein Namespace ist
use Vendor.Some.Other.Stuff
class MyClass > DerivedClass:
public myProperty:
get:
@TorbenKoehn
TorbenKoehn / captcha.php
Created November 14, 2013 12:12
A really old captcha system I found somewhere in my old codes.
<?php
//Simple Captcha Function
//Creates funny and not that easily readable captchas
// ================
// (c) 2009 by DarkDevine
// Modificate as you want, just keep some credits
// Fonts from http://urbanfonts.com , you can get new ones there as well
// ================
// Usage: generate_captcha( $mode ) for generating the captcha,
// check_captcha( $string) for checking with user input
@TorbenKoehn
TorbenKoehn / express-bind.js
Last active December 19, 2015 23:08
A simple module system for express (Node.js)
app.bind = function( entryPoint, middleware, module ) {
if( !module ) {
module = middleware;
middleware = null;
}
var methods = { get: 'get', post: 'post', put: 'put', delete: 'del' };
for( var i in module ) {