Skip to content

Instantly share code, notes, and snippets.

View dlundgren's full-sized avatar

David Lundgren dlundgren

View GitHub Profile
@dlundgren
dlundgren / keybase.md
Created August 14, 2015 22:31
keybase.md

Keybase proof

I hereby claim:

  • I am dlundgren on github.
  • I am dlundgren (https://keybase.io/dlundgren) on keybase.
  • I have a public key whose fingerprint is E53D 10BF C923 98E3 AA6D 8992 01F7 FF18 26F5 4D7F

To claim this, I am signing this object:

@dlundgren
dlundgren / ImmutableEntity.php
Created July 30, 2015 07:11
Idea for entities to act more java like with regards to private setters and public access to the properties
<?php
namespace Domain\Shared;
// create this separately
use Domain\Exception\InvalidProperty;
use Domain\Exception\Immutable;
/**
* Allows public access to the private properties of an object.
*
@dlundgren
dlundgren / BlocklistDe.php
Created January 29, 2015 17:55
Converts a Blocklist.de txt file from a list of IP's into a list with CIDR's on top and the rest of the ip's at the bottom.
<?php
/**
* Class BlocklistDe
*
* Parses a BlockListDe list text file and converts multiple hosts into CIDR notation
* if possible
*
* @author David Lundgren
* @license MIT
*/
@dlundgren
dlundgren / array_partition.php
Last active August 29, 2015 14:04
Partitions an array. Similar to array_chunk but goes through the array linearly
<?php
/**
* Partitions the array in a linear fashion.
*
* This is similar to array_chunk
*
* @param array $ary The array to partition
* @param int $partitions How many partitions should the array be split into.
* Default is to calculate off of the input array length
* @return array
@dlundgren
dlundgren / zf1_config_parambag.php
Created May 27, 2014 13:24
Zend Framework 1 Configuration ParameterBag for Symfony Dependency Injection
<?php
namespace dlundgren\Symfony\Component\DependencyInjection;
use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
use Symfony\Component\DependencyInjection\Exception\ParameterCircularReferenceException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
/**
* Holds parameters.
@dlundgren
dlundgren / check.php
Created October 22, 2013 20:31
partkeepr:: replacement function for isTimezoneSetAndValid()
<?php
/**
* Checks if the timezone is set and valid.
*
* @param none
* @return bool True if the timezone is set and valid, false otherwise.
*/
function isTimezoneSetAndValid () {
$tz = date_default_timezone_get();
if (empty($tz)) {