Wednesday, November 07, 2012

Mac OS X Preview reduce PDF size

Problem:

I have some (scanned) PDF documents which is a bit large (in a few MB) and want to reduce their size. The Preview app in Mas OS X has the function to reduce the PDF size but the resulted output is not clear enough to be useful.

To reduce PDF size in this way, we first open the PDF file in Preview. The select "File" -> "Export...". In the "Quartz Filter" option, select "Reduce File Size" and then "Save" the file with a new name. In one example, a 1.4MB colour scanned file is reduced to 65KB but the text is hardly readable.


Configuration:

Mac OS X 10.8.2


Solution: 

Open the "ColorSync Utility" from the "Applications" -> "Utilities" folder. On the lower left corner, click the "+" icon to add a new filter. You can name it as "PDF downsize".

Select this new filter and click the down arrow icon on the right. Select "Add Image Effects Component" -> "Color Image Sampling". In the newly created "Image Sampling" component, set the followings:

Scale : 100%
Resolution : <empty> Pixels / inch
Max : 1684 Pixels
Min : 512 Pixels
Quality : High

Click the down arrow icon again, this time, select "Add Image Effects Component" -> "Image Compression". In the newly created "Image Compression" component, set the followings:

Mode : JPEG
Quality : slide to around 25% towards Min

After these modifications, the "ColorSync Utility" can be closed.

Finally, open a terminal window (by "Applications" -> "Utilities" -> "Terminal". Then run the following command. Enter you root password if asked.

sudo mv ~/Library/Filters/PDF\ downsize.qfilter  /Library/PDF\ Services/

Now, you can select the "PDF downsize" filter in Preview and the above mentioned example is reduced from 1.4MB to 353KB with very readable result.

Tuesday, November 06, 2012

Disable auto generation of ~/Desktop ~/Documents ~/Downloads etc.

I prefer mwm and don't want any of the Gnome/KDE stuff on my (CentOS 6.3) desktop. But the system keep regenerating the following folders in my home directory.

Desktop  Documents  Downloads  Music  Pictures  Public  Templates  Videos

Solution:

Edith /etc/xdg/user-dirs.conf to set "enabled=False". Then remove the above directories and relogin again. Done!

Saturday, November 03, 2012

Problem of X11 forwarding

Problem:

When connected using the -X or -Y option with ssh, the following error is reported.

/usr/bin/xauth:  timeout in locking authority file /home/<user>/.Xauthority


Cause:

It is in fact caused by incorrect SELinux setting.


Solution:


# ls -alZ
drwxr-xr-x. uid gid   unconfined_u:object_r:home_root_t:s0 <user>
# chcon unconfined_u:object_r:user_home_t:s0 <user>
# ls -alZ
drwxr-xr-x. uid vid   unconfined_u:object_r:user_home_t:s0 <user>

Then login again, the xauth will create the .Xauthority automatically.

Wednesday, October 24, 2012

Macbook Air fan goes crazy

Scenario:

Out of nowhere, the fan of my Macbook Air goes crazy from time to time. Even I have been doing nothing but looking at the blank desktop wallpaper! Huge fan noise and the upper left corner of the Air (near the power inlet) becomes really hot.


Configuration:

2011 MacBook Air with 1.7GHz Intel Core i5, 4GB RAM and Mac OS X 10.8.2


Cause:

Checking at the activities in the machine, I found this process (displayed by the top command):

USER             PID  %CPU %MEM      VSZ    RSS   TT  STAT STARTED      TIME COMMAND
khtsoi           501  98.8  1.6  2606200  67320   ??  Rs    4:07PM   0:05.10 com.apple.quicklook.satellite

After searching the "Quicklook" and "Satellite" keywords in the Internet, some one suggested that the cause is Quicklook tries to call QuickTime to generate thumbnails for video files which are not supported by the QuickTime codec.

Then I realised that this process re-spawns itself every time when I click on the "Downloads" folder icon in the Dock. The default action of this click is to expand the folder contents in grid mode. Even I did not have any video/audio files in that folder, I noticed that the thumbnail of a M$ Word file is not rendered. All files after this Word file are also displayed as an empty box without the thumbnail image.

So, I fired up the "Activity Monitor" tool from the "Utilities" folder, select on the "QuickLookSatellite-general" process and click the "Inspect" icon from the tool bar. Under the "Open Files and Ports" tab, I confirm that the last thing this process trying to read is that M$ Word file.


Solution:

Everything is fine after removing the Word file from the "Downloads" folder. I can open that file with the M$ Word correctly and that file is 13MB. There are other M$ Word files in the same folder but they have never caused similar problem.


Edit: one more step to really get rid of the noise (in software level).

Problem:

The fan still goes crazy and the Air is still hot even the quick lock.satellite is gone. There is no heavy duty process showing up in top or the "Activity Monitor". But I notice there are something wrong in the system log. I found the following three errors message keep showing up in the system log (by going to "Applications" -> "Utilities" -> "Console" and select the "All Messages".)


mdworker[1626]: Unable to talk to lsboxd

sandboxd[1633]: ([1631]) mdworker(1631) deny mach-lookup com.apple.ls.boxd

kernel[0]: Sandbox: sandboxd(1627) deny mach-lookup com.apple.coresymbolicationd


Cause:

I don't know and I don't care. It's better to leave it to Apple to explain it to its customers.


Solution:

Step 1: Modify the system configure file (you need to be root to do so). Edit the /System/Library/Sandbox/Profiles/system.sb file to append the following three lines at the end:


;;; FixSandboxErrors
(allow mach-lookup (global-name "com.apple.ls.boxd"))
(allow mach-lookup (local-name "com.apple.ls.boxd"))

Step 2: Clear the cache (you need to be root to do so) by running the following command.

rm -fr /System/Library/Caches/*

Step 3: Safeboot the Mac.
 - Shutdown the Mac first (remember to enable speaker volume before shutdown).
 - Start up the Mac. Just after the startup tone (cannot do it before the tone), press and hold the shift key.
 - When the grey apply logo appears, release the shift key.
 - After the system is up to the login screen, confirm that there is a red "safeboot" label at the upper right screen corner.
 - Then you can simply restart the Mac.

Enjoy the Mac without the fan noise.

Monday, October 22, 2012

problem of ICC (ld: cannot find -lpthread)

Problem:

I cannot compile my old project using the Intel Compiler. The error reported is

ld: cannot find -lpthread

Cause:

Playing with the pthread library is not helpful. The real problem is the "-fast" option which enables "-xHOST -O3 -ipo -no-prec-div -static" by default.

But my current OS is CentOS 6.3 which hates static library. So the last "-static" option is the cause of the problem.

Solution:

Replace the "-fast" with "-O3 -ipo -no-prec-div".

Friday, October 19, 2012

Decision

I will join Imagination Tech in a month time. Submitted my resignation letter to Imperial College today. Heading to the unknown ...

Thursday, October 18, 2012

installing CUDA driver in CentOS 6.3

Problem: The new CUDA 5.0 is out. This time, a single package including the driver, development tools and example codes. But the installation cannot finish by keep asking for reboot.

Cause: The CentOS 6.3 kernel boots with the "nouveau" feature enabled.

Solutoin:

Edit the /boot/grub/grub.conf such that the kernel line with the following at the end of the line: rdblacklist=nouveau

Edit the /etc/modprobe.d/blacklist.conf to append "blacklist nouveau" after the last line. 

Thursday, October 11, 2012

Problem of sharing folder in CentOS guest by VMWare

Host: Mac OS X 10.8.2
VMWare 5.0.1
Guest: CentOS 6.3 x86_64

Problem:
Cannot share a folder in OS X to CentOS, the /mnt/hgfs directory is empty.
When toggle the on/off of folder sharing in VMWare options, it reports errors that cannot mount directory.

Cause: unknown!

Solution: Reinstall the VMWare tools by selection the "Virtual Machine -> Reinstall VMWare tools".

Wednesday, October 10, 2012

Problems when building project in Xilinx XPS/SDK 14.2

1.

Symptom: Missing the libz.so during SDK compilation.

Cause: My system is CentOS 6.3 x86_64. But the Xilinx tool "as" in the 64-bit EDK directory is actually a 32-bit ELF executable. It is looking for the 32-bit libz.so instead of the 64-bit installed version.

Solution: Install the 32-bit libz.so by
yum -y install libzip.i686"


2.

Symptom: Missing the xil_cache.h file when compiling the platform.c file in SDK.

Cause: There are modules, created by XSP/BSB, have capital letter(s) in their module name (e.g. LEDs_8Bits, etc.).

Solution: Exit XPS. Edit the *.MHS file. Change all "INSTANCE" name with lower case letters only.


3.

Symptom: The simulation in XPS seams endless without clock and reset.

Cause: The XPS does not create testbench by default so there is no drive to these signals.

Solution: Check the "generate simulation template" option in the project options.