Blog

I know you’ve got a big heart

I saw you draw it around

30 Oct 2011
/

Bash: how to copy permissions recursively

Imagine you were copying an, eg, virtual server from /server to /newserver, and messed permissions in /etc; thre’s a way to copy permissions with this simple script:  #!/bin/bash source=$1target=$2 echo "Copy files from $source to $target" cd $sourcefiles=`find $source` for file in $filesdo #this is some bash voodoo – string part replacement targetFile=$target${file#$source} #stat command can accept -c parameter

25 Oct 2011
/

Symfony 2 chrome firebug

If you use chrome to develop symfony 2 apps, install this extension https://chrome.google.com/webstore/detail/cjbeipenlpoeifpkjhgakejmikdhlhcj to view symfony generated firephp messages in console.

25 Oct 2011
/

Netbeans single variable type hinting

In some code blocks (especially in symfony DI related) it’s impossible to guess what class the object has, but it’s possible to use single-line annotation before assignment:  $object = $this->get(’doctrine’) ->getRepository(’MyBundleName:Object’) ->findOneById($id);/* @var $object \My\Bundle\Name\Entity\Object */  with this netbeans will be able to auto-complete $object-> calls. Please note that this annotation should be places after

20 Oct 2011
/

Doctrine/Symfony2 multiple database connections and Entity Managers

dbal: default_connection: default connections: default: dbname: database1 user: root password: password host: localhost other: dbname: database2 user: root password: password host: localhost orm: default_entity_manager: default entity_managers: default: connection: default mappings: MyFirstBundle: ~ other: connection: client mappings: MySecondBundle: ~ after that, you’ll be able to access the other database conneciton via:  $this->getDoctrine()->getEntityManager(’other’)  and  $this->getDoctrine()->getRepository(’Bundle:Entity’, ‘other’) 

20 Oct 2011
/

Custom twig extensions in symfony 2

To enable additional twig extensions in Symfony 2, e.g. “truncate” filter, add the following code in app/config/config.yml:  services: twig.extension.text: class: Twig_Extensions_Extension_Text tags: – { name: twig.extension }  

17 Oct 2011
/

ActiveMQ initscript

A quick’n’dirty ActiveMQ initscript, if activemq extracted to /opt/activemq. Enable with update-rc.d activemq defaults , LSB-tags present.  #! /bin/sh### BEGIN INIT INFO# Provides: activemq# Required-Start: $local_fs $all# Required-Stop:# Default-Start: 2 3 4 5# Default-Stop: 0 1 6# ActiveMQ message broker### END INIT INFO  case "$1" in start) /opt/activemq/bin/activemq start > /dev/null if [ $? -eq 0

14 Sep 2011
/

ISPCofnig mysql root pass

If you have ispconfig3 and forgot your root mysql pass, isconfig keeps it in /usr/local/ispconfig/server/lib/mysql_clientdb.conf )

21 Feb 2011
/

Symfony admin generator link with filters

Let’s assume you have module A in which you’d like to place a link to module B, and you also want this link to set filters in module B. To do this, you’ll have to use following code:  $filters = array(’query_string’ => ‘filter’, ‘filters’ => array(’a_id’ => $A->getId())); echo link_to(’Go and apply filter’, ‘b/index?’.http_build_query($filters));  Following this

10 Jan 2011
/

sfFormExtra TinyMCE do not mess urls

For tinymce not to mess up your pretty urls adding unnecessary ../../../.., pass the following parameter to sfWidgetFormTextareaTinyMCE contructor:   $this->widgetSchema[’text’] = new sfWidgetFormTextareaTinyMCE( array( ‘config’ => ‘convert_urls: false’ ) ); 

10 Jan 2011
/
theme by teslathemes