Chris Tate-Davies
The homepage of Chris Tate-Davies
The homepage of Chris Tate-Davies
Mar 18th
On a project I am working on, I need to enable language translation. Thinking about it, turned into something quite complicated. But then I found the Google Language API which allows developers to hook into the Google Languages services.
Mar 18th
We use ANT for releasing versions of our PHP applications. Its very smart and takes a lot of the problems related to releases out of the equation.
However, everytime we performed a release, our replication server would break, and I’d have to skip a load of database delta error messages with this command:
SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1
The error we received is:
Error 'Incorrect string value: 'x9CxF37x12[k...' for column 'applied_by' at row 1' on query. Default database: '<databasename>'.
Query: 'INSERT INTO changelog (change_number, delta_set, complete_dt, applied_by, description)
VALUES (35, 'Main', CURRENT_TIMESTAMP, USER(), '<database_delta_filename>')'.
I’d been getting these errors for a while.
Basically, the MySQL server was replicating the changelog table down to the slave, but for some reason it just would not accept the replicated query.
After a bit of scrummaging around, and changing field values/character sets, I discovered that in the string was “\x80″ which is a padding character as set out in http://en.wikipedia.org/wiki/ISO_8859-1 and shouldn’t be used in a string. I’m not really sure how it got there, or why, but I basically changed the “applied_by” field to be a BLOB – which is generically a VARCHAR with no character set and there fore ignores this.
Mar 18th
To ssh to another Lunix terminal, use this command:
ssh username@host -p port
The default SSH port is 21, but you could change it to anything, i.e. 9100
Remote teminal will prompt for your password, and job done.
cp – Copy file
cp /usr/bin/file /tmp/location
mkdir – Create directory/folder
mkdir /home/chris/newfolder
rm – Delete files in folder
rm -rf /home/chris/foldertoremove
The -rf tells Linux to remove files in the folder. This will remove all files and sub folders though, so be careful. There is no undelete.
mv – Rename a file, or move a file
mv /home/chris/index.htm /home/chris/home.htm
mv /home/chris/index.htm /home/chris/site/index.htm
The first command will rename a file, and the second will move it (effectively renaming it into another directory)
pwd – see what folder you are in
pwd
/home/chris/Desktop
Mar 18th
Checkout a branch:
svn checkout url@revision path
svn up
svn ci -m "message for commit" <files>
Multiple committing is just without the <files>.
svn co -r 1671<remotefolder> <localfolder>
http://www.mydomain.com/svn/project/trunk/folder
svn log -g <files>
Mar 18th
Very simple. but brain bending – All I wanted to do was remove a prefix from a string.
The prefix was always letters, and I only wanted the numerical suffix returned, so though, preg_replace was my best bet.
echo preg_replace("/[a-zA-Z]*/", '', '12345MystrING67890');
This returns :
1234567890
Perfect.