Skip to content

Instantly share code, notes, and snippets.

View ThijsFeryn's full-sized avatar

Thijs Feryn ThijsFeryn

View GitHub Profile
@ThijsFeryn
ThijsFeryn / Magento APC cache
Created June 22, 2012 11:37
Configuring Magento APC cache backend in local.xml
<global>
...
<cache>
<backend>apc</backend>
<prefix>MAGE_</prefix>
</cache>
...
</global>
@ThijsFeryn
ThijsFeryn / Magento Memcached cache
Created June 22, 2012 11:49
Configuring Magento Memcached cache backend in local.xml
<global>
...
<cache>
<backend>memcached</backend>
<memcached>
<servers>
<server>
<host><![CDATA[127.0.0.1]]></host>
<port><![CDATA[11211]]></port>
<persistent><![CDATA[1]]></persistent>
apc.max_file_size = 10M
apc.shm_size = 128M
@ThijsFeryn
ThijsFeryn / Command line PHP example
Created June 26, 2012 07:48
Command line PHP example
$ php test.php
@ThijsFeryn
ThijsFeryn / PHP command line arguments
Created June 26, 2012 08:04
Working with arguments in PHP on the command line
$ php cli.php arg1 arg2
@ThijsFeryn
ThijsFeryn / gist:2994304
Created June 26, 2012 08:09
Working with arguments in PHP on the command line
<?php
echo "There are {$argc} passed: ".PHP_EOL;
foreach($argv as $k=>$v){
echo "Argument {$k}: {$v}".PHP_EOL;
}
@ThijsFeryn
ThijsFeryn / gist:2994370
Created June 26, 2012 08:25
Working with I/O streams in PHP
$ php test.php < test.txt
@ThijsFeryn
ThijsFeryn / gist:2994393
Created June 26, 2012 08:31
Working with I/O streams in PHP
<?php
$stdin = fopen('php://stdin', 'r');
$stdout = fopen('php://stdout', 'w');
$stderr = fopen('php://stderr', 'w');
while(!feof($stdin)){
$line = trim(fgets($stdin));
if(strlen($line) > 0){
fwrite($stdout,strrev($line).PHP_EOL);
} else {
@ThijsFeryn
ThijsFeryn / gist:2994427
Created June 26, 2012 08:36
Short syntax for PHP command line I/O streams
<?php
while(!feof(STDIN)){
$line = trim(fgets(STDIN));
if(strlen($line) > 0){
fwrite(STDOUT,strrev($line).PHP_EOL);
} else {
fwrite(STDERR,"An empty line was passed".PHP_EOL);
}
}
@ThijsFeryn
ThijsFeryn / gist:3034005
Created July 2, 2012 16:11
Syntax highlighting using the PHP command line
$ php -s test.phps
<code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">if(</span><span style="color: #0000BB">$_REQUEST</span><span style="color: #007700">[</span><span style="color: #DD0000">'a'</span><span style="color: #007700">]&nbsp;==&nbsp;</span><span style="color: #DD0000">'b'</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'Some&nbsp;output'</span><span style="color: #007700">;<br />}<br /></span>
</span>
</code>
$