Posts by Robin
domain matching regex
A regular expression that validates a given domain without its top level domain. I didnt need to validate the tld because this comes from a selectbox, so its predefined and always valid. The http protocol or the second level domain www. are both optional, it can be written or not. $regex = “/^(?:(http:\/\/)?)(?:(w{3}\.)?)([A-Z0-9\-".utf8_encode("äÄöÖüÜ")."]{3,})$/i”; if(!preg_match($regex,$domainname)) { [...]
Telefonnummern Routing-Problem
Unser geschäftlicher ISDN Telefonanschluss kann von diversen Anrufern nicht erreicht werden, derjenige erhält entweder ein Besetztzeichen, oder sofern er vom Mobiltelefon aus anruft die Information dass Netz sei belegt. Bei den Telefonanbietern ist dieses Problem bekannt, scheinbar wird aber nicht gerne darüber mit dem Kunden gesprochen oder diskutiert – Bereits vor unserem Wechsel des Telekommunikationsanbieters [...]
truncate text-strings without cutting words
This is an easy way to truncate strings without cutting words after n characters. bad one: Lorem ipsum dolor sit amet, hy… good one: Lorem ipsum dolor sit amet, hymenaeos … $string = “Lorem ipsum dolor sit amet, pellentesque wisi ut congue eget quam.”; $strLength = 30; echo substr ( $string, 0, strrpos ( $string, [...]
Webhostingday 2009
Die diesjährigen Webhostingdays fanden vom 18. bis 20. März bei Köln in Brühl auf dem Gelände des Phantasialands statt. Hier trafen sich etwa 2000 interessierte Besucher aus der ganzen Welt die sich innovative Produkte und Dienstleistungen vorstellen ließen, sich die spannenden Vorträge der Unternehmen aus der Hosting- und IT-Branche anhörten, sich untereinander austauschten und nebenbei [...]
set multilingual pageTitle in a view or element
I have searched for a long time until i found the reason why i couldnt make a pageTitle multilingual in a view or in an element. First I tried to edit the title in this way and became unhappy because it was written in the content area of my page and not in the titletag. [...]
Installing Prototype/Scriptaculous into your CakePHP App
I wanted to install the prototype framework with the scriptaculous effects to my cakePHP Application, but after uploading the prototype files into the webroot/js folder and linking them in the layout, i got a failure message like “Undefined variable: javascript”. This variable has to be defined in the Applications Helper, so you can put this [...]
Removing folders content except specific files or subfolders
I often need to remove files or folders in a dierctory – but I also often must not delete the whole directory, so here is the shell syntax for removing everything from a directory excepting your searchparameter. This removes all files and subfolders in your current folder, excepting the cgi-bin directory. ls | grep -v [...]
search a string within a gzip file
You can search within possibly compressed files for a regular expression. This helps me searching for strings in old compressed logfiles. zgrep [ grep_options ] [ -e ] pattern filename… This greps “searchstring” (without case sensitivity) from the compressed file in filename.gz and writes the results to a new file with the name Result. zgrep [...]
search and replace strings from file
Searching and replacing strings from a file can be done with sed. sed ‘s/’SEARCH_STRING’/'REPLACE_STRING’/g’ filename > new_filename Tweet
extracting specific files from a tarball
If you have a big tarball and you dont want to extract all files and folders of it, you can use grep to extract only specific files or folders. tar xfvkp Backup_23-06-07.tar.gz $(tar tf Backup_23-06-07.tar.gz | grep ‘mySpecific/Folder’) Tweet