Skip to content

Instantly share code, notes, and snippets.

View joelhinz's full-sized avatar

Joel Hinz joelhinz

  • Falkenberg, Sweden
View GitHub Profile
@joelhinz
joelhinz / mer-ioc.php
Last active November 25, 2016 13:46
mer ioc!
<?php
// en global helper
function stats($object = null)
{
$cache = App::make('statistics-cache');
return $object ? $cache->resolve($object) : $cache;
}
@joelhinz
joelhinz / prisoners2.js
Created November 5, 2016 11:07
The twelve prisoners, shorter version
var _ = require('lodash');
function run() {
var piles = _.chunk(_.shuffle(_.range(52).map(i => Math.floor(i/4))), 4);
return iterate(piles[0].shift(), piles);
}
function iterate(hold, piles) {
if (_.range(1, 13).every(i => piles[i].length === 0)) return true;
if (piles[0].length == 0 && hold === 0) return false;
@joelhinz
joelhinz / prisoners.js
Created November 5, 2016 11:07
The twelve prisoners, OOP
var _ = require('lodash');
class Card {
constructor(value) {
this.value = value;
}
}
class Deck {
@joelhinz
joelhinz / RedirectIndexPhpCalls.php
Last active March 6, 2019 08:08
Laravel 5 redirect index.php calls middleware
<?php
namespace App\Http\Middleware;
use Closure;
class RedirectIndexPhpCalls
{
/**
* Handle an incoming request.
### Keybase proof
I hereby claim:
* I am joelhinz on github.
* I am joelhinz (https://keybase.io/joelhinz) on keybase.
* I have a public key whose fingerprint is 63AF 6064 1A80 DB28 7F95 2EFD 9393 3C45 018E 4679
To claim this, I am signing this object: