Skip to content

Instantly share code, notes, and snippets.

Dennis Jungbauer d4rkne55

  • Germany
Block or report user

Report or block d4rkne55

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@d4rkne55
d4rkne55 / JsonDumper.class.php
Created Sep 20, 2019
Class for dumping/beautifying JSON
View JsonDumper.class.php
<?php
class JsonDumper
{
/** @var string */
private $json;
/** @var int spaces to use for one indentation level */
private $indentation;
@d4rkne55
d4rkne55 / AsciiTable.class.php
Created Sep 20, 2019
Class for drawing cool ASCII tables, including data
View AsciiTable.class.php
<?php
class AsciiTable
{
private $rows;
private $columns;
private $headers = array();
private $data = array();
private $separators;
private $headerPadMethod;
@d4rkne55
d4rkne55 / NumberSpell.class.php
Last active Sep 21, 2019
Class for getting the spelled out string of a number (was a coding challenge once)
View NumberSpell.class.php
<?php
class NumberSpell
{
public $number;
public $spelled;
private $rules = array(
0 => array('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'),
1 => array(null, 'twen', 'thir', 'for', 'fif', null, null, null, null)
@d4rkne55
d4rkne55 / DateIntervalEnhanced.class.php
Last active Sep 21, 2019
A DateInterval extension class
View DateIntervalEnhanced.class.php
<?php
/**
* This class brings support for milliseconds, explicit recalculation of carry-over points
* and human-friendly formatting
*/
class DateIntervalEnhanced extends DateInterval
{
public $ms = 0;
private $unitData = array(
@d4rkne55
d4rkne55 / StringTransform.class.php
Last active Oct 5, 2018
Class for some transformations on Strings
View StringTransform.class.php
<?php
class StringTransform
{
/**
* This Method Converts a String to Title Case
* Not context-aware and just for english.
*
* @param string $str
* @param bool $apStyle use AP-Style title case if true
@d4rkne55
d4rkne55 / Media.class.php
Last active Sep 20, 2019
Class with some calculations and informations for media files
View Media.class.php
<?php
class Media
{
public $calcBase = 1024;
public $fileSize = 0;
public $sizePrefixes = array(
1000 => array(
'',
'K',
@d4rkne55
d4rkne55 / parseColorString.php
Created Mar 9, 2017
This function is for parsing legacy color values. It is based on the WHATWG specs.
View parseColorString.php
<?php
function parseColorString($str, $format = 'hex') {
$str = strtolower(trim($str));
// prevent errors for an empty string and ignore 'transparent'
if ($str == '' || $str == 'transparent') {
return false;
}
// replace nonvalid hex characters with 0
You can’t perform that action at this time.