Skip to content

Instantly share code, notes, and snippets.

Avatar

Wojciech Sznapka wowo

View GitHub Profile
View symfony1.2-doctrine1.1-workaround-in-admin-generated-module
<?php
/*
* class generated by symfony framework (v.1.2) with Doctrine 1.0
* after switching to doctrine 1.1 objects saved in admin generated modules won't include many-to-many relations
* the solution is to overload doSave method and swap two lines below
*
* let me know if you have better idea :-) twitter.com/sznapka
*/
class BasePackageForm extends BaseFormDoctrine
View gist:267944
class A
{
int i = 1;
public int print()
{
System.out.println(" z klasy A ");
return i;
}
}
public class B extends A
View symfony-ShowPictureInBrowser
<?php
class dummyActions extends sfActions
{
/**
* remember: never use readfile function here! it sends headers to browser, so those sent by you are useles
* also don't echo file and then return sfView::NONE - echoing should be done in views!
*
* this method is environment independent, you can use it in _prod, _dev etc,
* alsoWeb Debug Toolbar can be turned on
*/
View losowanieLiczbyWZaleznosciOdDnia
<?php
/**
* Losowanie liczby w zależności od aktualnego dnia
*/
$days = array(
0 => array(11, 88), //niedziela
1 => array(5, 2), //poniedzialek
2 => array(3, 7), //wtorek
3 => array(2, 9), //sroda
4 => array(55, 22), //czwartek
View andNav2-mapTilesFileStructureFix
<?php
$path = ($tmp = $_SERVER['argv'][1]) ? $tmp : '.';
foreach (scandir($path) as $filepath) {
if (strpos($filepath, '\\')) {
$properFilepath = str_replace('\\', '/', $filepath);
@mkdir(dirname($properFilepath), 0777, true);
rename($filepath, $properFilepath);
}
}
@wowo
wowo / databases.yml
Created Nov 8, 2010
Konfiguracja projektu w symfony pod Test Driven Development
View databases.yml
test:
doctrine:
class: sfDoctrineDatabase
param:
dsn: 'sqlite::memory:'
@wowo
wowo / fixtures.list
Created Nov 8, 2010
Lista ponumerowanych fixtures
View fixtures.list
01cars_and_users.yml
02fuels.yml
03prices.yml
@wowo
wowo / model.php
Created Nov 8, 2010
Plik model.php używany jako bootstrap dla testów lime
View model.php
<?php
$ROOT_DIR = sprintf("%s/../../", dirname(__FILE__));
$TEST_DIR = sprintf("%s/test/", $ROOT_DIR);
include sprintf("%s/bootstrap/unit.php", $TEST_DIR);
$configuration = ProjectConfiguration::getApplicationConfiguration("car", "test", true);
$dbManager = new sfDatabaseManager($configuration);
Doctrine::createTablesFromModels(sprintf("%s/lib/model", $ROOT_DIR));
View weirdestPhpConstructionIHaveEverSeen.php
<?php
class myClass
{
public function myPublicMethod()
{
function uglyFunction()
{
echo "le fu-";
}
@wowo
wowo / arrayWalkUsingClosure.php
Created Nov 14, 2010
Easy way of removing new lines in every attribute of an object - with closures in PHP 5.3
View arrayWalkUsingClosure.php
<?php
class Operation
{
public $dateOperation;
public $datePosting;
public $type;
public $description;
public $priceOriginalCurrency;
public $pricePln;