libpng error: IDAT: CRC error

I receive this error message while using wkhtmltoimage.

In Mac, it it not allow you to use Preview to save to other format.
It will display cannot write, or enable to save.

The fastest way to solve this problem, can be done in Automator, you can use Photo -> Flip Image -> Flip Image then save or convert to other format.

Then your PNG error will be gone.

Fix Safari for Slow and Loading by Disable DNS Prefetching

I’m wondering why Safari on my Mac always slower load on facebook.com, but fast in Google Chrome. I did set the DNS for my network to Google DNS 8.8.8.8 and 8.8.4.4 and it doesn’t help much.

facebook.com reverse the IP differently from different location, if your browser prefetching it, maybe slow down from the previous IP you get. So I tried to disable the DNS Prefetching using the Terminal.

[code lang=”bash”]
defaults write com.apple.safari WebKitDNSPrefetchingEnabled -boolean false
[/code]

If I want to re-enable again, I can run this in Terminal.
[code lang=”bash”]
defaults delete com.apple.safari WebKitDNSPrefetchingEnabled
[/code]

I feel that the loading speed is faster than before.

Fastest way to rename filenames with space to dash in linux

I want to mass rename hundred of filenames like
filename 001.jpg to filename-001.jpg



filename 099.jpg to filename-099.jpg

I use this command to rename all in few seconds in my MacBook Pro.
I think it is fine to run in any linux.
[code lang=”bash”]
for f in *\ *; do mv "$f" "${f// /-}"; done
[/code]

Show Image Size in Terminal or Shell

The easiest way to show the file size in Terminal in Mac or Linux.
[code lang=”bash”]
ustins-MacBook-Pro:jpg juzhax$ file 001.jpg
001.jpg: JPEG image data, EXIF standard
Justins-MacBook-Pro:jpg juzhax$ identify 001.jpg
001.jpg JPEG 720×468 720×468+0+0 8-bit sRGB 59.8KB 0.000u 0:00.009
Justins-MacBook-Pro:jpg juzhax$
[/code]

command c expects followed by text error in Mac

You received error from the sed command in Mac, because the argument in mac is different.
If you type in Mac terminal, you may receive error like this
[code lang=”bash”]
Justins-MacBook-Pro:2 juzhax$ sed -i ‘s/old_text/new_text/g’ example.txt
sed: 1: "config.php": command c expects \ followed by text
[/code]

The first argument should be the extension of the backup file. The correct way is
[code lang=”bash”]
Justins-MacBook-Pro:2 juzhax$ sed -i ‘.bak’ ‘s/old_text/new_text/g’ example.txt
[/code]

or

[code lang=”bash”]
Justins-MacBook-Pro:2 juzhax$ sed -i ‘.original’ ‘s/old_text/new_text/g’ example.txt
[/code]

If you don’t want any backup file, you can do like this.
[code lang=”bash”]
Justins-MacBook-Pro:2 juzhax$ sed -i ” ‘s/old_text/new_text/g’ example.txt
[/code]

How to convert pvr.czz file to PNG ?

Download TexturePacker

Install and it does support command line tools.

To convert single pvr.czz file to PNG in console, here is the way.
[code lang=”bash”]
TexturePacker filename.pvr.ccz –sheet filename.png –data dummy.plist –algorithm Basic –allow-free-size –no-trim
[/code]

To convert mass pvr.czz file to PNG in console, here is the way.
[code lang=”bash”]
find -name \*.pvr.czz | sed ‘s/\.pvr.czz//g’ | \
xargs -I % -n 1 TexturePacker %.pvr.czz \
–sheet %.png \
–data dummy.plist \
–algorithm Basic \
–allow-free-size \
–no-trim
[/code]

invalid object in plist for destination format

Error: invalid object in plist for destination format

When you convert the .plist file to json, you could see this problem


plutil -convert json -e json ./filename.plist
./filename.plist: invalid object in plist for destination format

Solution

Remove the key and date using any editor, then re convert again.

 

<key>some text</key>
<date>2013-06-20T15:31:58Z</date>