Friday, June 28, 2013

Enable Xdebug in MAMP

Uncomment the zend_extension line and modify the /Applications/MAMP/bin/php/php5.x/conf/php.ini file to look like this:-
; On my machine, the default port 9000 has already been taken by something else.
; Recommended when using Symfony
Then restart the servers in MAMP.


Show print history on Mac

When I opened the web based CUPS admin interface to show print history:-
I got the "Internal Server Error" message.

To fix it, I used the following commands
sudo cupsctl --debug-logging
sudo cupsctl --no-debug-logging

Wednesday, June 26, 2013

Custom php.ini on shared hosting

  • Find the default php.ini path. Mine is /usr/local/lib/php.ini
<?php phpinfo() ?>
  • Copy the default php.ini to the user's home folder and customise it.
<?php copy("/usr/local/lib/php.ini", "/home/username/php.ini") ?>
  • Create a .htaccess file in the user's home folder with the following content.
SetEnv PHPRC /home/username/php.ini
# The following lines are important if the php.ini file is put in the document root.
<Files php.ini>
order allow,deny
deny from all

Monday, June 24, 2013

List processes and ports on Mac

  • Show listening ports
lsof -i -nP | grep LISTEN
or with all processes
sudo lsof -i -nP | grep LISTEN
  • Show ports with any state, e.g. ESTABLISHED, CLOSE_WAIT, CLOSED, LISTEN
sudo lsof -i -nP | grep TCP
sudo lsof -i -nP | grep UDP
-i select IPv[46] files
-n no host names
-P no port names


Friday, June 14, 2013

The system is running in low-graphics mode after upgrading the VirtualBox Guest additions to 4.2.12

I tried switching to use gdm instead of lightdm to see whether it could help but it didn't so I rolled back to v4.2.10 while waiting for v4.2.13 which was reported that this problem has been fixed.
  • Rebooted the machine in recovery mode in the Grub menu by, while booting:- 
    • Pressing ESC, or
    • Holding down the Shift key (this works better for me).
  • Uninstalled the VirtualBox Guest additions
cd /opt/VBoxGuestAdditions-4.2.12
  • After reboot, the screen was black. Here is what I did to fix this,
    • Pressed Cmd + F1 (or Alt + F1, don't know why Ctrl isn't needed on my machine) to switch to tty1.
    • Made LigthDM the default display manager
sudo dpkg-reconfigure lightdm
sudo reboot
        But it didn't work. It turned out that I also had to modify /etc/X11/default-display-manager to have the full path to lightdm like this.
Then rebooted,
sudo reboot
After that, I could continue installing the VirtualBox Guest additions v4.2.10 and now everything is back to normal.


Saturday, June 1, 2013

Install httrack using brew on Mac

brew install httrack
Then I got:-
==> Downloading downloaded: /Library/Caches/Homebrew/httrack-3.46.1.tar.gz
Error: SHA1 mismatch
Expected: be6328d2ff3cbabd21426b7acc54edcf1ebb76e0
Actual: 237fca7a9c5c63b53c5d0134dac6e5714422384c
Archive: /Library/Caches/Homebrew/httrack-3.46.1.tar.gz
(To retry an incomplete download, remove the file above.)
So I did:-
brew update
Then I got:-
error: The following untracked working tree files would be overwritten by merge:     Library/Formula/libmusicbrainz.rbPlease move or remove them before you can merge.AbortingError: Failure while executing: git pull -q origin refs/heads/master:refs/remotes/origin/master
To fix it, I did:-
cd /usr/local
git fetch origin
git reset --hard origin/master
After that, I could run "brew update" and "brew install httrack" again with no problem.