If I set the value of posts_per_page variable on query_posts to a lower value than that set on the settings page than I will get the 404 error.
Example: settings set to 10 posts per page [$ppp = get_option('posts_per_page') will echo 10]
posts_per_page set to 3 on query_posts
If I have a total of 9 posts on my wordpress database then, with the settings above, page two will not show and I get the 404 error!
Teaching WordPress is a good experience.
Teaching WordPress is a good experience.
Canvas Padded thumbnails using PHP and GD in Zend Framework Application
function showThumbnail($imageFileName='', $width='', $height='', $cwidth='', $cheight='')
{
$cfg = new Zend_Config_Ini(APPLICATION_PATH.'/configs/application.ini', 'production');
$path = $cfg->resources->frontController->imageupload->path;
$publicpath = $cfg->resources->frontController->imageupload->publicpath;
$pi = pathinfo($imageFileName);
$filename = $pi['filename'];
$ext = $pi['extension'];
$thumbname = $filename.'-'.$width.'X'.$height.'.'.$ext;
$fspath = APPLICATION_PATH.'/..'.$path.'/'.$imageFileName;
$fspathThumb = APPLICATION_PATH.'/..'.$path.'/'.$thumbname;
if(!file_exists($fspathThumb)) {
thumb($fspath, $width, $height, $cwidth, $cheight, $fspathThumb);
}
return $publicpath.'/'.$thumbname;
}
function thumb($img, $w, $h, $cw='', $ch='', $thumb, $fill='') {
if (!extension_loaded('gd') && !extension_loaded('gd2')) {
trigger_error("No dispones de la libreria GD para generar la imagen.", E_USER_WARNING);
return false;
}
$imgInfo = getimagesize($img);
switch ($imgInfo[2]) {
case 1: $im = imagecreatefromgif($img); break;
case 2: $im = imagecreatefromjpeg($img); break;
case 3: $im = imagecreatefrompng($img); break;
default: trigger_error('Tipo de imagen no reconocido.', E_USER_WARNING); break;
}
if ($imgInfo[0] <= $w && $imgInfo[1] <= $h) {
$nHeight = $imgInfo[1];
$nWidth = $imgInfo[0];
}else{
if ($w/$imgInfo[0] < $h/$imgInfo[1]) {
$nWidth = $w;
$nHeight = $imgInfo[1]*($w/$imgInfo[0]);
$ny = ($h - $nHeight)/2;
}else{
$nWidth = $imgInfo[0]*($h/$imgInfo[1]);
$nHeight = $h;
$nx = ($w - $nWidth)/2;
}
}
$nWidth = round($nWidth);
$nHeight = round($nHeight);
$newImg = imagecreatetruecolor($nWidth, $nHeight);
$newImg = imagecreatetruecolor($w, $h);
$fillColor = imagecolorallocate($newImg, 0xFF, 0xFF, 0xFF);
imagefill($newImg, 0, 0, $fillColor);
imagecopyresampled($newImg, $im, $nx, $ny, 0, 0, $nWidth, $nHeight, $imgInfo[0], $imgInfo[1]);
switch ($imgInfo[2]) {
case 1: imagegif($newImg , $thumb); break;
case 2: imagejpeg($newImg, $thumb); break;
case 3: imagepng($newImg, $thumb); break;
default: trigger_error('Imposible mostrar la imagen.', E_USER_WARNING); break;
}
imagedestroy($newImg);
}
SVN Post Commit hook
Some days ago, I got a requirement of giving access to 3 users to my SVN repo over ssh.
#groupadd dev
#useradd -g dev auser
#useradd -g dev buser
#useradd -g dev cuser
Then set the passwords for each user.
For SVN, update changes, you need to have the working copy owned by dev group
#chmod 0775 -R myworkingcopy
#chown -R apache:dev myworkingcopy
For svn post commit hook
#chown apache:dev post-commit
#chmod 0755 post-commit
The point here is that the user committing the changes should have the write permissions to the working copy and execute permissions on the post-commit hook
and all is good.
MVC .htaccess with exclusion of .html files
RewriteEngine on
RewriteRule ^\.htaccess$ - [F]
RewriteRule ^(.*)\.html$ - [L]
RewriteCond %{REQUEST_URI} =""
RewriteRule ^.*$ /public/index.php [NC,L]
RewriteCond %{REQUEST_URI} !^/public/.*$
RewriteRule ^(.*)$ /public/$1
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [NC,L]
RewriteRule ^public/.*$ /public/index.php [NC,L]
Zend Framework Project .htaccess with exclusion of folders
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^\.htaccess$ - [F]
RewriteRule ^(blog|forum)($|/) - [L]
RewriteCond %{REQUEST_URI} =""
RewriteRule ^.*$ /public/index.php [NC,L]
RewriteCond %{REQUEST_URI} !^/public/.*$
RewriteRule ^(.*)$ /public/$1
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [NC,L]
RewriteRule ^public/.*$ /public/index.php [NC,L]
Exporting unversioned files with SVN
You can just use cp -r to copy the directory tree directly, and then remove the .svn directories afterwards:
# cp -r x
# cd x
# find . -name .svn -type d -exec rm -r ‘{}’ \;
Drop Down menu hiding behind Flash in internet explorer
For this you have to make the flash movie transparent. set the wmode property to transparent in the flash object
Google Map Polygons draw internet explorer unspecified error
if you are using jQuery to initialize google Map, do not user $(function(){ initialize()}) or $(document).ready(function(){initialize()}).
Always use $(window).load(function(){ initialize() }). This worked for me.
Installing python 2.7.1, mysql-pythondb and PIL (python Imaging Library) on centos
yum -y install gcc gdbm-devel readline-devel ncurses-devel zlib-devel bzip2-develsqlite-devel db4-devel openssl-devel tk-devel bluez-libs-devel make
cd /var/tmp
wget http://www.python.org/ftp/python/2.7.1/Python-2.7.1.tgz
tar xvfz Python-2.7.1.tgz
cd Python-2.7.1
./configure --prefix=/opt/python2.7.1 --with-threads --enable-shared
make
make install
touch /etc/ld.so.conf.d/opt-python2.7.1.conf
echo "/opt/python2.7.1/lib/" >> /etc/ld.so.conf.d/opt-python2.7.1.conf
ldconfig
ln -sf /opt/python2.7.1/bin/python /usr/bin/python2.7
cd /var/tmp
wget http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg
sh setuptools-0.6c11-py2.7.egg --prefix=/opt/python2.7.1
/opt/python2.7.1/bin/easy_install pip
ln -sf /opt/python2.7.1/bin/pip /usr/bin/pip
pip install virtualenv
ln -sf /opt/python2.7.1/bin/virtualenv /usr/bin/virtualenv
echo "alias python=/opt/python2.7.1/bin/python" >> ~/.bash_profile
echo "alias python2.7=/opt/python2.7.1/bin/python" >> ~/.bash_profile
echo "PATH=$PATH:/opt/python2.7.1/bin" >> ~/.bash_profile
source ~/.bash_profile
# install mysql python db
cd /var/tmp
pip install http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.3/MySQL-python-1.2.3.tar.gz/download
#install PIL
yum install libjpeg freetype
pip install http://effbot.org/downloads/Imaging-1.1.7.tar.gz