Skip to content

Instantly share code, notes, and snippets.

View wowo's full-sized avatar

Wojciech Sznapka wowo

View GitHub Profile
@wowo
wowo / privateVisibilityFromTheOtherObjects.php
Created November 16, 2010 01:52
Accessing private members of the same object type
<?php
class Foo
{
private $_property = "Foo";
public function get()
{
return $this->_property;
}
@wowo
wowo / php.ini
Created November 19, 2010 21:12
Ustawienia zabezpieczające przed session fixation
session.use_trans_sid = 0
session.use_cookies = 1
session.use_only_cookies = 1
@wowo
wowo / streamDecompresViaHttp.php
Created November 23, 2010 21:45
Decompresses gz archives on the fly while downloading from remote server
<?php
$path = "http://sznapka.pl/myarchive.gz";
$data = file_get_contents("compress.zlib://" . $path);
printf("Got from %s archive such content:\n%s", $path, trim($data));
// prints:
// Got from http://sznapka.pl/myarchive.gz archive such content:
// Hi, I'm gz-ipped and you can ungzip me and download on the fly :-)
@wowo
wowo / xsjobs_1.php
Created November 30, 2010 08:58
XS Jobs tricky question - what will be output of the script?
<?php
foreach (range(1,5) as $value) {
if ($value == 2)
continue
print "$value\n";
}
@wowo
wowo / php53-closures-question.php
Created December 8, 2010 08:35
Quick question to check PHP 5.3 knowledge
<?php
$guys[] = "Robert, age 24";
$guys[] = "Alice, age 19";
$guys[] = "Jacob, age 29";
array_walk($guys, function (&$guy) {
$guy = preg_replace_callback("#^\w{2}\w+#", function($value) {
$value = current($value);
for ($i = 2; $i < strlen($value); $i++) {
<?xml version="1.0"?>
<AfasGetConnector>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="AfasGetConnector">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="GetOpenAmounts">
<xs:complexType>
<xs:sequence>
<xs:element name="Subnummer" type="xs:string" minOccurs="0"/>
<?xml version="1.0"?>
<AfasGetConnector>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="AfasGetConnector">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="GetMatchedPayments">
<xs:complexType>
<xs:sequence>
<xs:element name="Subnummer" type="xs:string" minOccurs="0"/>
#!/bin/bash
USER=`whoami`
CURRENT=${PWD##*/}
echo ">> Searching for $CURRENT"
BUNDLE=`grep $CURRENT /tmp/bundles_$USER/felix-cache -rin | head -1 | awk -F "/" '{print $5}'`
echo ">> Found bundle $BUNDLE"
TARGET=`find . -name *.jar`
@wowo
wowo / dynamic_vhost.conf
Created March 22, 2011 15:43
Dynamic Apache2 vhost configuration
<VirtualHost *:80>
VirtualDocumentRoot "/var/www/%1/web/"
<Directory "/var/www/%0/web">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
@wowo
wowo / BaseTestCase.php
Created June 14, 2011 21:18
Base test case with container (Symfony2)
<?php
require_once(__DIR__ . "/../../../../app/AppKernel.php");
class BaseTestCase extends \PHPUnit_Framework_TestCase
{
protected $_container;
public function __construct()
{