Thursday, November 17, 2011

Fix for iTunes' "Network connection timeout" error

I have been trying to update my iPhone to iOS 5.0 for a few days now. Every time the software download would fail one third way through with "Network connection timeout" on Win7 x64 host.

It took me a while to dig out the solution that worked for me:

  1. Upgrade to the latest version of iTunes.
  2. Flush DNS Cache.
    Start command prompt and run:
    c:\>: ipconfig /flushdns 
     
  3. Disable FireWall and Anti-Virus software
If none of that worked for you, you might need to download the software update file (IPSW) manually from Apple site directly. Google for "download-iphone-firmware-ipsw."

The folder to place downloaded update is:

c:\Users\USERNAME\AppData\Roaming\Apple Computer\iTunes\iPhone Software Updates\

The filename of the recent update for me was:

     iPhone3,3_5.0.1_9A405_Restore.ipsw 

Tuesday, September 13, 2011

Technical Drawings with Dia

Dia is an excellent multi-platform diagram drawing tool originally written by Alexander Larsson. Unlike Visio, it works well on Windows and Linux, and best part -- it is free.

I have been using it for a good part of the last 10 years and always enjoy its functionality.

The most unintuitive aspect of embedding Dia drawings into your Microsoft Word document or PowerPoint presentation is how to export the drawing to appropriate picture format.

Before you start working on your drawing with Dia, change drawing setting to these:
  • File|Page Setup to:
    1. Paper Size: Letter
    2. Scaling: 45
  • Under View menu item:
    1. Select AntiAliased
    2. Unselect Snap To Objects
Now, proceed with your drawing diagram. You can disregard the fact that it might span over multiple pages. When you are finished, go back to File|Page Setup and change Scaling of it to Fit to: 1 by 1. This will rescale your drawing to fit in a page. The reason for that is the physical constraint of Microsoft Word document which is page-oriented.

Now you are ready to export your drawing from Dia internal XML format to one of the compressed graphics formats such as JPEG, GIF, or PNG.
Open 'Export Diagram' dialog via File|Export. We are going to use PNG as graphics file format as it works well in the documents and on the web across all imaginable platforms.

The trick is to select the right PNG format out of all available which are:
  • Cairo PNG (*.png)
  • Cairo PNG (with alpha) (*.png)
  • Pixbuf[png] (*.png)
  • PNG (anti-aliased) (*.png)
The right format would be the last available, PNG (anti-aliased).

When selected, press 'Save' button and then a little dialog 'diaw.exe' pops up to let you specify PNG Export Options. This is very important as you can set Image width of your final picture.

For Microsoft Word document I set Image widht to 800 and let the dialog adjust the height.

For PowerPoint presentation, set it to 1200 and also remember to have your document orientation set to Landscape in the File|Page Setup we did at the beginning.

When you import the picture in your Word document, you can resize it to better fit the flow of your text.

Friday, June 17, 2011

Formatting Source Code with astyle

astyle is a source code indenter, formatter, and beautifier for the C, C++, C# and Java programming languages. It is cross-platform and gets the job done pretty well.

I use a combination of these switches to get code formatted to my liking:

#!/bin/sh
#
# Name: indent++
#
astyle \
    --style=1tbs \
    --indent=tab=4 \
    --indent-switches \
    --indent-preprocessor \
    --convert-tabs \
    --break-blocks \
    --break-closing-brackets \
    --unpad-paren \
    --pad-header \
    --pad-oper \
    --pad-paren-out \
    --add-brackets \
    --align-pointer=type \
    --align-reference=type < $file > $file.indented

mv $file $file.orig
mv $file.indented $file