Skip to content

Instantly share code, notes, and snippets.

@ScreamingDev
ScreamingDev / index.php
Created November 10, 2012 22:17
PHP PSR-0 Autoload (with Phar)
/**
* Enhanced PSR-0 autoloader with Phar-Support
*
* @param $class string Name of the class (with namespace)
*
* @author Ralf Mike Pretzlaw <[email protected]>
* @copyright 2012 Ralf Mike Pretzlaw
*
* @throws Exception
*/
@ScreamingDev
ScreamingDev / class.php
Created November 11, 2012 02:10
PHP CLI Class for logging warning quiet and verbose
namespace CLI;
class Log
{
protected $_verbose = false;
protected $_debug = false;
protected $_quiet = false;
protected function _log ( $message, $lineFeed = true )
{
@ScreamingDev
ScreamingDev / installJDK64.sh
Created November 21, 2012 22:11
Install JAVA JDK 64
#!/bin/sh
#
# Requires: JDK
# Optional: Mozilla Firefox
# TODO A 20121121 path as variable
# TODO B 20121121 tar JDK
#
# install
@ScreamingDev
ScreamingDev / Defer\Unset.php
Created December 16, 2012 08:08
Deffered Statements solution with PHP
<?php
/**
* @author Mike Pretzlaw
* @link http://hallo-php-welt.de
* @copyright Mike Pretzlaw
*
* Example:
<?php
function foo() { $bar = "handle"; $unset = new Defer\Unset($bar); throw new Exception(); }
?>
@ScreamingDev
ScreamingDev / gist:4461356
Last active December 10, 2015 16:29
Apache2 Subdomain Config
# NameVirtualHost subdomain.example.tld:80
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName subdomain.example.tld
ServerAlias subdomain.example.tld
DocumentRoot /var/www/subdomain.example.tld
# PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.5
# PassengerRuby /usr/bin/ruby1.8
@ScreamingDev
ScreamingDev / exchangeArray.php
Last active December 15, 2015 15:19
Exchange Array
<?php
$default = [
'one' => null,
'two' => null,
];
$incoming = ['two' => 123, 'three' => 345];
// only allow existing keys
@ScreamingDev
ScreamingDev / Form.php
Created April 2, 2013 12:45
Mage - Adminhtml - Form fields (simple)
<?php
// text
$fieldset->addField('title', 'text', array(
'label' => Mage::helper('form')->__('Title3'),
'class' => 'required-entry',
'required' => true,
'name' => 'title',
'onclick' => "alert('on click');",
'onchange' => "alert('on change');",
@ScreamingDev
ScreamingDev / static-trap.php
Last active December 16, 2015 04:49
PHP Trap in Functions with static variables
<?php
class A
{
function __construct()
{
echo get_class($this->getInstance()), PHP_EOL,
get_class(static::getInstance()), PHP_EOL,
get_class(self::getInstance()), PHP_EOL;
}
$methodName = $this->getName();
foreach ($this->getParameters() as $param)
{ /** @var \ReflectionParameter $param Iterate over possible params */
$currentParam = '';
if ($param->isPassedByReference())
{
$currentParam = '&';
}
@ScreamingDev
ScreamingDev / up.sh
Last active December 17, 2015 14:39
Get the latest for all repos in your project map / directory
#!/bin/sh
#
# requires: https://github.com/aanand/git-up
# run in the dir you keep your projects
#
for dir in `find -maxdepth 1 -mindepth 1 -type d`;
do # update git and run xdeploy