Skip to content

Instantly share code, notes, and snippets.

View d1rk's full-sized avatar
🖖
Live long and prosper!

Dirk Brünsicke d1rk

🖖
Live long and prosper!
View GitHub Profile
@d1rk
d1rk / CommandLine.php
Created March 13, 2013 08:43
simple utility class to parse command line arguments (or similar from strings) into a useful array. Taken from http://www.php.net/manual/en/function.array-shift.php#93084
<?php
/**
* CommandLine class
*
* @package Framework
*/
/**
* Command Line Interface (CLI) utility class.
*
* @author Patrick Fisher <[email protected]>
@d1rk
d1rk / virtual.conf
Last active January 15, 2018 19:24 — forked from tmaiaroto/virtual.conf
nginx configuration with subdomain variable extracting
#
# A virtual host using mix of IP-, name-, and port-based configuration.
# This is based on using Homebrew for OS X. You can use this in other
# cases though, but you'll likely need to adjust some of the paths below.
#
server {
# Replace this port with the right one for your requirements
# listen 80 [default|default_server]; #could also be 1.2.3.4:80
<?php
namespace app\models;
class Url extends \lithium\data\Model {
protected $_schema = array(
'_id' => array ('type' => 'id'),
'url' => array('type' => 'string'),
'slug' => array('type' => 'string')
);
@d1rk
d1rk / Form.php
Last active January 15, 2018 19:25 — forked from wms/Form.php
overwrite li3 default Form->input() to be more bootstrap-ready.
<?php
namespace app\extensions\helper;
class Form extends \lithium\template\helper\Form {
/**
* String templates used by this helper.
*
* @var array
@d1rk
d1rk / CONTRIBUTING.md
Last active December 11, 2015 23:28
common github files

Contributing

Getting Started

  • Submit a ticket and mention that you are working on it.
  • Send pull requests to the master branch.
  • In the pull request or the commit message, tell us which issue this is for.
  • Topic branches are encouraged but not enforced.
  • Changes must have unit tests and updated documentation.
  • Validate all existing tests and new tests are successful.
  • Validate your new code meets lithium coding standards.
@d1rk
d1rk / Base.php
Created September 20, 2012 10:58 — forked from nateabele/Base.php
MongoDB-based model accessors (relationships) in Lithium
<?php
namespace my_app\models;
use MongoId;
use lithium\data\collection\DocumentArray;
use lithium\data\collection\DocumentSet;
use lithium\data\entity\Document;
use lithium\util\Inflector;
use lithium\core\Libraries;
@d1rk
d1rk / errors.php
Created August 28, 2012 18:46 — forked from rmarscher/errors.php
li3 airbrake in errors bootstrap
<?php
use lithium\action\Response;
use lithium\core\Environment;
use lithium\core\ErrorHandler;
use lithium\core\Libraries;
use lithium\console\Response as ConsoleResponse;
use lithium\net\http\Media;
use lithium\analysis\Logger;
use lithium\net\http\Service;
@d1rk
d1rk / cron.php
Created May 16, 2012 14:28 — forked from tmaiaroto/cron.php
Lithium Cron Wrapper
<?php
/**
* This script is meant to be executed via crontab.
* It should help you easily set li3 commands as cron jobs.
*
* You should put this in the root of your application.
* However, you don't need to, but you would then need to
* pass a --path= option with the path to your app.
* This is because the li3 console command must be called
* from a specific location.
@d1rk
d1rk / blowfish.php
Created May 14, 2012 09:21 — forked from xeoncross/blowfish.php
blowfish hashing using PHP's crypt and mcrypt library
<?php
# From my question and answer at SO:
# http://stackoverflow.com/questions/10183103/security-of-generating-hash-salts-using-phps-mt-rand
function blowfish($string, $salt = NULL, $iterations = '12')
{
return crypt($string, $salt ?: "$2a\$$iterations$" . md5(mcrypt_create_iv(22, MCRYPT_DEV_URANDOM)));
}
@d1rk
d1rk / example.php
Created March 27, 2012 13:32
parsing an xdebug dump into something meaningful
<?php
xdebug_start_trace('/tmp/mytrace');
// do stuff
xdebug_stop_trace();
?>