When you validate you XML Xliff file you have often the problem that a trans-unit node has no or a already existing id. So i have wrote a small script for that problem.
fix_id.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| <?php
$doc = new DOMDocument();
$doc->load($argv[1]);
$xpath = new DOMXPath($doc);
$query = '//trans-unit';
$entries = $xpath->query($query);
foreach ($entries as $i => $entry) {
$entry->setAttribute('id', $i+1);
}
$doc->save($argv[1]); |
Execute the following command in your symfony1 root directory
for FILE in `find apps/*/i18n -name *\.xml`; do php fix_id.php $FILE; done;
To change all your code from Doctrine to Doctrine_Core you can use the following command
1
| for fl in `find apps/ config/ lib/ test/ -name *.php`; do mv $fl $fl.old; sed 's/Doctrine::/Doctrine_Core::/g' $fl.old > $fl; rm -f $fl.old; done |
When you have a plugin you can use this command
1
| for fl in `find . -name *.php`; do mv $fl $fl.old; sed 's/Doctrine::/Doctrine_Core::/g' $fl.old > $fl; rm -f $fl.old; done |
call this from your project root
for DIR in `find lib -name base -type d`; do svn propset svn:ignore base $DIR/..;svn rm $DIR; done;
Problem
I need more then one memcached server.
Solution
Virtual machine
I can build for each memcached server a virtal machine.
Problems
- more memory (system+memcached)
- one ip address for each instance
- more work
Multiple instances via ports
For this it needs to patch the init.d and start-memcached scripts to run multiple instances.
After the patch it search for configuration files that match the following pattern /etc/memcached_*.conf. When it found no file it use the /etc/memcached.conf configuration file. So it breaks no backward compatibility.
When you want to create 2 memached instances copy the configuration file and change the port, memory …
cp /etc/memcached.conf /etc/memcached_myserver_1.conf
cp /etc/memcached.conf /etc/memcached_myserver_2.conf
Commands
start all servers
/etc/init.d/memcached start
start only a specific server
/etc/init.d/memcached start myserver_1
stop all servers
/etc/init.d/memcached stop
stop only a specific server
/etc/init.d/memcached stop myserver_1
The patches
/usr/share/memcached/scripts/start-memcached
26,30d25
> if (scalar(@ARGV) == 2) {
> $etcfile = shift(@ARGV);
> $pidfile = shift(@ARGV);
> }
>
/etc/init.d/memcached
16a17
> DAEMONNAME=memcached
18d18
< NAME=memcached
20d19
< PIDFILE=/var/run/$NAME.pid
26a26,63
> FILES=(/etc/memcached_*.conf);
> # check for alternative config schema
> if [ -r "${FILES[0]}" ]; then
> CONFIGS=();
> for FILE in "${FILES[@]}";
> do
> # remove prefix
> NAME=${FILE#/etc/};
> # remove suffix
> NAME=${NAME%.conf};
>
> # check optional second param
> if [ $# -ne 2 ];
> then
> # add to config array
> CONFIGS+=($NAME);
> elif [ "memcached_$2" == "$NAME" ];
> then
> # use only one memcached
> CONFIGS=($NAME);
> break;
> fi;
> done;
>
> if [ ${#CONFIGS[@]} == 0 ];
> then
> echo "Config not exist for: $2" >&2;
> exit 1;
> fi;
> else
> CONFIGS=(memcached);
> fi;
>
> CONFIG_NUM=${#CONFIGS[@]};
> for ((i=0; i < $CONFIG_NUM; i++)); do
> NAME=${CONFIGS[${i}]};
> PIDFILE="/var/run/${NAME}.pid";
>
30c67
< start-stop-daemon --start --quiet --exec $DAEMONBOOTSTRAP
---
> start-stop-daemon --start --quiet --exec "$DAEMONBOOTSTRAP" -- /etc/${NAME}.conf $PIDFILE
50c87
< start-stop-daemon --start --quiet --exec $DAEMONBOOTSTRAP
---
> start-stop-daemon --start --quiet --exec "$DAEMONBOOTSTRAP" -- /etc/${NAME}.conf $PIDFILE
54c91
< N=/etc/init.d/$NAME
---
> N=/etc/init.d/$DAEMONNAME
59a97
> done;
Some questions some awnsers. For each command you can find more options with
How can i show the difference between two files or directories?
simple use diff
- -r rekursive
- -w –ignore-all-space ignore space
- -y –side-by-side show both files side by side
How can i copy with the same right, group and user settings?
with the option -a
How can i show metacharacters like special whit spaces?
use cat
How can i get one file from a SVN source?
svn export http://framework.zend.com/svn/framework/standard/tags/release-1.7.6/library/Zend/Acl.php
How can i remove all .svn folder from a folder and his subfolders?
for DIR in `find . -name .svn -type d`; do rm $DIR -Rf; done;
How can display a directory as a tree?
simple with tree
Recent Comments