Jan 2, 2012
Posted by Coen on Jan 2, 2012 in Bash / CL | 0 comments
#!/bin/sh
#
# Script to search recursively for a string in the current directory
#
if [ "" == $1 ]
then
echo "Please specify a string to search for."
else
grep -ril $1 .
fi
If you want to look for a string in specific files, you can do the following:
#!/bin/sh
#
# Script to search recursively for a string in the current directory
#
find . -type f -name $1 -exec grep -rilo $2 {} \;
grep:
-r = recursive
-i = ignore case distinctions
-l = only print FILE names containing matches
-o = show only the part of a line matching PATTERN
VN:F [1.9.14_1148]
Dec 28, 2010
Posted by Coen on Dec 28, 2010 in (Cake)PHP | 0 comments
/app/config/database.php code:
var $connectionName = array(
'driver' => 'mysql'
, 'persistent' => false
, 'host' => 'localhost'
, 'login' => 'your-username'
, 'password' => 'your-password'
, 'database' => 'your-database'
, 'prefix' => ''
);
In a random model:
$this->useDbConfig = 'connectionName';
VN:F [1.9.14_1148]
Mar 21, 2011
Posted by Coen on Mar 21, 2011 in (Cake)PHP | 0 comments
Cause: you’re sending your e-mail as HTML only.
Solution: send the e-mail as “both”, like this:
$this->Email->sendAs = 'both';
VN:F [1.9.14_1148]
Apr 27, 2011
Posted by Coen on Apr 27, 2011 in Bash / CL | 0 comments
First you want to see which files will be deleted. This examples looks for files older than 7 days.
find /directory/to/search/through/ -type f -mtime +7 -print | xargs echo
If you’re satisfied with the list, you can actually delete them:
find /directory/to/search/through/ -type f -mtime +7 -print | xargs rm -f
VN:F [1.9.14_1148]
Feb 8, 2011
Posted by Coen on Feb 8, 2011 in (Cake)PHP | 0 comments
Before you perform your save, execute a create first. This prevents data from being overwritten due to an ID being set that you didn’t know about.
$this->Model->create();
$this->Model->save($aYourData);
VN:F [1.9.14_1148]
Jan 3, 2012
Posted by Coen on Jan 3, 2012 in SEO | 0 comments
Add the following to your .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{http_host} ^yourdomain.com [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]
</IfModule>
VN:F [1.9.14_1148]