Blog

Redmine rack initscript

Seems like the only normal way to run redmine is with rack  ruby script/server -e production   and this simple initscript:  #!/bin/bash ### BEGIN INIT INFO # Provides: redmine # Required-Start: $local_fs $all # Required-Stop: # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Redmine issue tracker ### END INIT INFO  case

26 Nov 2011
/

Direct links to controller without global routing rules in sf2

I suppose anyone is aware about path() twig function; it takes route name and returns URL. This is cool, but what if you use @Route annotation in Controller and need to link there without modifying routing.yml? Here some magic comes in place – symfony internally generates name for each route imported via @Route annotation; the

23 Nov 2011
/

Setting PHPUnit for symfony projects on Ubuntu

Just a copy& paste guide:  #install pear, phpunitsudo apt-get install php-pear phpunit #upgrade pear – this is necessarysudo pear upgrade PEAR #install phpunitsudo pear config-set auto_discover 1sudo pear install pear.phpunit.de/PHPUnit  All done! Now you can run symfony tests:  cd vendor/symfonyphp vendors.phpphpunit -c phpunit.xml.dist tests/ 

19 Nov 2011
/

PHP wildcard matching function

Just published my PHP wildcard matching function on github – https://github.com/andrewtch/phpwildcard. See doc there and use it like this:  wildcard_match(’foo.*’, ‘foo.xy’); //truewildcard_match(’foo.?’, ‘foo’); //false  array wildcard matching is supported too:  wildcard_match(’foo.*’, array(’boo.bar’, ‘foo.buz’, ‘buz.bar’) // array(‘foo.buz’) 

17 Nov 2011
/

LR <-> Paypal exchanger

Found a good one: www.gaxee.com. Seems to support WMZ / WMR to PayPal too!

16 Nov 2011
/

Symfony2 – how to find current environment

If you ever need to do some logic only in test/dev environments in symfony2, you can do it the following way:  if(in_array($this->get(’kernel’)->getEnvironment(), array(’test’, ‘dev’))) { //do something here} 

14 Nov 2011
/

AppKernel and DependencyInjection container in Symfony 2 tests

It’s fairly simple to use app kernel and DI container in symfony tests, just require AppKernel.php:  require_once __DIR__.’/../../../../../../app/AppKernel.php’;  and then boot your app in setUp method:    private $container;  public function setUp() { $this->app = new \AppKernel(’test’, true); $this->app->boot(); $this->container = $this->app->getContainer(); }   then, use a container where needed:   public function testFoo() { $this->container->get(’logger’)->debug(’Foo’);

09 Nov 2011
/

bash – stripping newlines and replacing with spaces

For example, if you have an linux shell command output, newline-separated, and need to convert output to space-separated, pipe it to tr “\n” ” ” like so:  dpkg -l | grep php | cut -d " " -f 3 | tr "\n" " " 

06 Nov 2011
/

Hello, world!

This is a first post in a category dedicated to simple JavaScript dependency injection container. Check repo on github: https://github.com/andrewtch/js-di

02 Nov 2011
/

Openvz Munin CPU monitoring

Found a wonderful plugin to monitor CPU usage on openvz containers: http://exchange.munin-monitoring.org/plugins/openvzcpu/version/3/raw

31 Oct 2011
/
theme by teslathemes