Posts RSS Comments RSS Del.icio.us Digg Technorati Blinklist Furl reddit 125 Posts and 30 Comments till now
This wordpress theme is downloaded from wordpress themes website.

Archive for the 'Computers / Tech' Category

gcc optimization flags – debug vs release

gcc (or g++ for C++ code) has varying optimization levels.  Specific types of code or target platforms (such as embedded) might benefit from an alternate gcc flag.  But for most situations, you can use –O0 for debug build and –O2 for release build.  The default is –O0.  An old friend (who is an Economics specialist) ran into this because he wanted to write a fairly simple C++ application for Economics data simulation, that would be cross-platform.

His XCode build ran noticeably faster (such as 2 sec vs. 54 sec) than when he used g++ directly on Mac OS X, or g++ in cygwin on Windows, or g++ on Linux.  So I took his initial code and got it to build using Qt Creator 2.0.0 on Windows 7.  I noticed the g++ optimization flags when looking at Qt Creator’s make files (which use qmake and gcc / g++) (notice the -O2 part) (this is from Makefile.Release):

CC            = gcc
CXX           = g++
DEFINES       = -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DQT_CORE_LIB -DQT_THREAD_SUPPORT
CFLAGS        = -O2 -Wall $(DEFINES)
CXXFLAGS      = -O2 -frtti -fexceptions -mthreads -Wall $(DEFINES)

I’m sure I used gcc directly like this at some point (at least in college).  However, if you use a tool that abstracts this (such as Qt Creator, or Linux make files that someone else on the team wrote 5 to 15 years ago) or an alternative (such as Visual Studio C++, C#, Python, Java), then it’s pretty easy to not be aware of this very basic gcc detail.  One of my long-term goals is to continue to be a fairly cross-platform OS user and developer (Windows, Mac, Linux / *nix).

I liked this story since it’s a simple example of how spending just a little bit of time (helping a fellow coder – even if he/she is not a hardcore full-time software developer) or (doing a hobby project) put me just a little outside the daily experience of my day job, and enabled me to learn something useful.  This was also a great excuse to play some more with Qt Creator.

Begin http://www.network-theory.co.uk/docs/gccintro/gccintro_49.html

6.4 Optimization levels

In order to control compilation-time and compiler memory usage, and the trade-offs between speed and space for the resulting executable, GCC provides a range of general optimization levels, numbered from 0–3, as well as individual options for specific types of optimization.

An optimization level is chosen with the command line option -OLEVEL, where LEVEL is a number from 0 to 3. The effects of the different optimization levels are described below:

-O0 or no -O option (default)
At this optimization level GCC does not perform any optimization and compiles the source code in the most straightforward way possible. Each command in the source code is converted directly to the corresponding instructions in the executable file, without rearrangement. This is the best option to use when debugging a program and is the default if no optimization level option is specified.
-O1 or -O
This level turns on the most common forms of optimization that do not require any speed-space tradeoffs. With this option the resulting executables should be smaller and faster than with -O0. The more expensive optimizations, such as instruction scheduling, are not used at this level. Compiling with the option -O1 can often take less time than compiling with -O0, due to the reduced amounts of data that need to be processed after simple optimizations.
-O2
This option turns on further optimizations, in addition to those used by -O1. These additional optimizations include instruction scheduling. Only optimizations that do not require any speed-space tradeoffs are used, so the executable should not increase in size. The compiler will take longer to compile programs and require more memory than with -O1. This option is generally the best choice for deployment of a program, because it provides maximum optimization without increasing the executable size. It is the default optimization level for releases of GNU packages.
-O3
This option turns on more expensive optimizations, such as function inlining, in addition to all the optimizations of the lower levels -O2 and -O1. The -O3 optimization level may increase the speed of the resulting executable, but can also increase its size. Under some circumstances where these optimizations are not favorable, this option might actually make a program slower.
-funroll-loops
This option turns on loop-unrolling, and is independent of the other optimization options. It will increase the size of an executable. Whether or not this option produces a beneficial result has to be examined on a case-by-case basis.
-Os
This option selects optimizations which reduce the size of an executable. The aim of this option is to produce the smallest possible executable, for systems constrained by memory or disk space. In some cases a smaller executable will also run faster, due to better cache usage.

It is important to remember that the benefit of optimization at the highest levels must be weighed against the cost. The cost of optimization includes greater complexity in debugging, and increased time and memory requirements during compilation. For most purposes it is satisfactory to use -O0 for debugging, and -O2 for development and deployment.

End http://www.network-theory.co.uk/docs/gccintro/gccintro_49.html

Begin http://stackoverflow.com/questions/796162/g-compiler-flags-optimization-and-flags-for-making-a-static-library-c

The rule of thumb:

When you need to debug, use -O0 (and -g to generate debugging symbols.)

When you are preparing to ship it, use -O2.

When you use gentoo, use -O3…!

When you need to put it on an embedded system, use -Os (optimize for size, not for efficiency.)

End http://stackoverflow.com/questions/796162/g-compiler-flags-optimization-and-flags-for-making-a-static-library-c

Blogging Good Eats Time

Overall, I’ve mostly failed so far to turn this blog into summaries of my recent / current hobby projects (and what concepts and technologies etc I learned).  It’s a time sink just to do any hobby projects (in addition to the already limitless supply of code work and relevant study for me to do for my paid job).

I tend to keep a lot of notes as I’m working on something (both paper and electronic).  But converting those into concise and meaningful blog posts usually costs resources (time and effort / focus) that could be spent elsewhere.

That said, I’ve elected to at least share a brief one about very basic gcc / g++ use.

iTunes: CD to audiobook, podcast to music

Import Audiobook into iTunes
* from http://www.cnet.com.au/how-to-create-audio-books-in-itunes_p7-339293735.htm#vp
* import CD into iTunes (with standard iTunes), AAC is the successor to mp3, although Apple Lossless is lossless
* Get Info -> Options -> Media Kind is Audiobook, Remember position is Yes,
* Get Info -> Info, specify Artwork, etc
* Rename files, such as (Ch. 1) to (Ch. 01)

Convert Podcast to Music using this same method:
* Get Info -> Options -> Media Kind is Music, Remember position is Yes,
* Get Info -> Info -> Genre -> change from Podcast to your new preference

iTunes_MediaKind

iPad survey from AT&T – my responses

I got a survey from AT&T about the iPad.  Here’s my some of the responses I gave.

How satisfied? 9/10 because…  I think it’s clearly the best out there, but that’s really only because it was first to market, for this type of oversized tablet device.

What do you like the most about the iPad?

It’s useful for reading, writing, internet access, video.  The screen size and the thinness is great size for reading web pages, magazines, comics, pdf / doc files, emails, video, etc.  Unlike a netbook, I can leave it on all day, without significant problems with stability or heat.  It’s great to hold and use in hands, or read while laying down, or put on a stand and type with the Apple wireless keyboard.  Having 802.11 a/n and the awesome no contract $15/mo AT&T wireless plan (that you can upgrade to $30/mo only when you need it) is a real game changer.

What do you dislike the most about the iPad?

1st, I really think there should be a central file system.  It’s fine to give each app its own private file area too.  But there’s a lot of files I want to have in central location, and open with different apps.  For example, I’d like to sync my entire set of DropBox files to one folder (on iPad and iPod).  And I’d like to sync a folder from my Windows computer to one folder (on iPad and iPod).  Then I should be able to open particular files, from the central file system, from each app.  If I want to open the same file from two different apps, I shouldn’t have (and manage) two copies of the file!  The user has to jump through so many hoops with this "think different" lack of a central file system.  It can be really annoying.

2nd, There are two things which make it difficult to suggest for children and people in my family who use computers more casually.  One, even $500 each is expensive, at least if you buy 4 or 5 or 6 of them.  Two, I’m not confident that a person can really use it without sync’ing to a real computer.  If someone, such as a parent with multiple children, has to decide between a laptop or an iPad, it’s probably going to be the laptop first, since the iPad kind of needs a computer (using iTunes).

3rd, Would be nice if the already awesome AT&T no contract data plan included WiFi on planes.

4th, It’s not often, but sometimes an app, or even the OS, will crash or freeze.  I’ve even had the Mail app freeze while I was writing an email, and it didn’t save a draft, so I had to retype the email.  This happens less on other devices…  But since iPad doesn’t multi-task, and doesn’t let me install OS level stuff (like a clipboard manager with clipboard history), it can be more damaging when something does crash.

My 1st and 2nd dislikes are the biggest.

Did you comparison shop for other devices?  No to iPhone and other smart phones.  Yes to netbook, notebook/laptop, e-reader, other (tablets such as Android).

I am on the internet more than 6 hours a day.  Duh

iPad kind of replaces my laptop – but I think that’s only temporary.  I have both a (normal more powerful desktop) and a (mac mini for travel between two residences).  However, as laptops improve in terms of weight, battery life, always-on-capabilities, power…  I am likely to someday carry both a laptop and iPad.  Of course it would help if both the iPad and laptops reduce their weight a little more.

What I’d really like to do is carry one ARM iPad, one keyboard-less x86 laptop tablet, and one keyboard that can easily fast-switch which of the two it controls (and also turn on/off faster, maybe using a switch or a toggle button – instead of having to hold down a button for 3 seconds).  I want to carry one keyboard, not two.  The same bluetooth keyboard should let me fast-switch between iPad and x86 tablet, and to even a 3rd device too, such as my mac mini.  There are some bluetooth headsets that let you pair to more than one device.

I didn’t say this in the survey…  But it more replaces a netbook or an e-reader than a laptop.  I bolded the text about having a bluetooth keyboard that lets you store multiple profiles (such as 3) and fast-change between them, to switch which bluetooth device you are connected to.  That is really a huge deal.

Overall, I think most people would pick between (a desktop vs. a laptop), rather than (a laptop vs. an iPad).  Though I am looking forward to (more powerful, lighter weight, lower heat, longer battery life) keyboard-less multi-touch x86 Windows 7 tablets (or Mac OS X) (especially with better mobile GPU’s, such as AMD/ATI Fusion products).

iPad_ATT_01

Windows credentials breaks domain account?

I faced an annoying problem with my Windows account in a corporate network (at my day job).  IT security makes our passwords expires after 90 days, so you have to change your Windows account password.  I change the password.  Then it locks me out.  I ask IT to reset the password, and it works.  Then shortly thereafter, it locks me out again.  It kept locking me out.

IT thought this might just be an issue of waiting for the password to sync.  But I had another idea.  My local Windows 7 machine is not on the domain, and it still had the old password cached, such as for credentials as seen in (Control Panel\User Accounts and Family Safety\Credential Manager).  You can also get there from Run -> control userpasswords2 -> Advanced -> Manage Password.

Unfortunately, as far as I could tell, you can only delete them one at a time, and it’s really slow…  It takes 3 clicks per removal, plus each time you remove one it scrolls you back up to the top of the window.

So many things are wrong with this entire situation.  Everything involved is Microsoft Windows technology, yet it manages to horribly break itself.  The error shouldn’t happen in the first place.  But the bad UI makes it so much more painful.

WindowsDomain_03

Here’s one post that at least attempts to help troubleshoot the issue:

http://social.technet.microsoft.com/Forums/en/w7itprosecurity/thread/0f88e0b6-7aa0-4917-bd06-68f77f14493e

-> http://technet.microsoft.com/en-us/library/cc773155%28WS.10%29.aspx

Customizable Permalinks plugin by Yahoo, broken

In my previous post, I mentioned how the WordPress “Customizable Permalinks” plugin prevents me from using WordPress for iPad (iPod touch, etc), by breaking the XML RPC.

wp-admin –> Settings –> Permalinks linked to more info here ( http://codex.wordpress.org/Using_Permalinks ).  Default uses “?p=N” (post number), while pretty permalinks let you specify other formats, such as “yyyy/mm/dd/post-name”.

For yahoo web hosting, this didn’t work, and I think it has something to do with the .htaccess file, or yahoo’s particular web server.  The Yahoo “Customizable Permalinks” plugin makes the permalinks work, but it causes the XML RPC to break.

In any event, I ended up going to “wp-admin/options-permalink.php”, and changing it to Custom Structure “/index.php/%year%/%monthnum%/%day%/%postname%/”.

custom_permalinks_01

This allowed me to have the prettier custom url structure permalinks, yet still have XML RPC work.  There may be a way to take out the “index.php”, even with Yahoo web hosting, but I didn’t look very hard yet…  So maybe someone else knows the answer?

WordPress for iPad

I’m writing this using WordPress for iPad.

Overall, it’s very good news just that it works. Although, it didn’t work instantly, since when I tried to connect to my wordpress blog, it gave me an error relating to the xml rpc xml protocol. This had happened when I first tried WordPress for iPhone, so I knew to try disabling plugins, which fixed the problem. The offending plugin was "Customizable Permalinks".

Unfortunately, the app is pretty bare bones, such as compared to Windows Live Writer (a Windows desktop app).

Sadly, it’s frozen and crashed, and even had the save button disappear while editing a post… All within 5 minutes of using it. Since you can save drafts, it’s not the end of the world, but kind of annoying.

For editing an existing post, it’s only edit mode shows the HTML – no WYSIWYG.

Overall, it’s awesome that there is a WordPress app for iPad, and it at least has the basic functionality working. The functionality is not particularly amazing, but it has some reasonable basic functionality and a nice iPad UI.

If you type "http:", a popup box asks if you want to make a link.

To publish, you tap "Status" and change from "Local Draft" to "Published". You can also choose "Draft", which is awesome, since that syncs to my WordPress blog, which allows me to continue to edit the post from somewhere else (before I publish), such as Windows Live Writer (on Windows 7 desktop OS).

It lets you attach photos, which is great.  Although what I did for this post was attach the photos, then copy/paste them using the Windows Live Writer plugin “Clipboard Image” (Clipboard Capture).  This is so I can more easily use (or tweak) a standard size for (the thumb image and the larger image).

The ability to moderate posts (ie, mark as “Approve” or as “Spam”) is also very useful / convenient.

Finally, the bad news is that disabling the WordPress Customizable Permalinks plugin caused my page’s post links to no longer work… So until I fix that issue, it’s not very convenient to blog from the WordPress iPad app.

iPad_WordPress_01[1] iPad_WordPress_02[1]

iTunes crash problem / fix

After I upgrade to iTunes 9.1.1.12, iTunes would crash every time I open it.  I tried repair, then uninstall / reinstall, but this didn’t fix it.  Then I did this:
1) rename my iTunes_Media media folder (such as to iTunes_Media_)
2) open iTunes, close iTunes
3) rename the folder back to iTunes_Media

This appeared to fix the problem.  Until I tried (File –> Library –> Organize Library –> Consolidate files), and iTunes crashed again.

To narrow it down, I went through this rather painful process:
1) close iTunes, rename a folder inside iTunes_Media
2) open iTunes, try consolidate files to see if crashes (alt, f, b, l, c, enter)

It turned out that 5 of my author-named folders had broken audiobooks.  Yet they had working copies with “ 1.aa” at the end.  So I deleted the “my file.aa” copies, and renamed the “my file 1.aa” copies to “my file.aa”.

I’m guessing this means that the file was somehow corrupted.  I’m not sure what caused this.  But regardless of whether or not it was iTunes, this really shouldn’t make iTunes crash…  Instead, iTunes should list which files are corrupted.

iTunes_crash_fix_01

Gmail filters – skip the inbox

I do pretty much the same thing with tags (Gmail) as I do with folders (Outlook Exchange).  I have rules to filter particular emails into a folder (or a tag).

In Gmail, you can do this when you create a new filter.  Or, to do this for existing filters, you go to Settings –> Filters, and for each filter you do Edit –> Next Step –> check Skip the Inbox (also check, also apply to the conversations below).

gmail_filters_01

iPad keyboards

The iPad supports bluetooth 2.1 keyboards.  But there’s two keyboards in particular that Apple is initially pushing.

iPad_keyboards_01_dock

The iPad Keyboard Dock has special function buttons on the top row: home button, search button (redundant since you can just press the home button twice?), brightness down, brightness up, picture frame mode toggle, software keyboard toggle, a mysterious unlabeled button, music/video media controls (track left, pause/play toggle, track right), volume mute, volume up, volume down, screen lock.  One thing I like about it is that the bottom left keys are (Control, Option, Command).

However, the deal breaker is that the keyboard is attached to the dock, and the dock doesn’t fold – so this makes it less portable.

iPad_keyboards_02

When you checkout from the online Apple store with an iPad, the other keyboard they try to sell you is the Apple Wireless Keyboard.  I’ve used one at a Best Buy display, and I think it’s pretty slick overall (in particular, it’s small size).  However, I’m not sure how well it would fit in my laptop bag next to the iPad, with that raised cylinder.  The other concern is whether the F keys work the same as with the iPad keyboard dock.  I am hopeful that they do, even though they are labeled differently.

However, the deal breaker is that the bottom left keys are (Fn, Control, Option, Command).  The position of the Fn key is confusing for shortucts.

A similar thing that may kill me, regardless of what I do, is that, when I use Mac OS X, I remap Command to Control (and Control to Command), so that most Windows shortcuts (like ctrl+X, ctrl+C, ctrl+V – cut, copy, paste) work the same.  I am doubtful about this being easy to do on the iPad.  I know it’s close-minded, but shortcuts like cut copy paste are for my left pinky finger – not my left thumb!!!

For now, I’m waiting to hear more info about specifically how the iPad works with the specific keyboard keys…  And whether they will release another Apple Wireless Keyboard (for iPad) that doesn’t have the Fn key.  Or another iPad Keyboard Dock, that is more portable.

Update: I still don’t like that the wireless keyboard has a Fn key.  And it looks like you can’t remap the keyboard keys (like I do on Mac OS X, swapping control and command).  So you still have to do (Cmd+X, Cmd+C, Cmd+V) for (cut, copy, paste), which is the Windows equivalent of having to do (Alt+X, Alt+C, Alt+V) instead of (Ctrl+X, Ctrl+C, Ctrl+V) – in terms of the hand positioning (muscle memory for keyboard shortcuts).  However, overall, my biggest gripe is that I want an Apple wireless keyboard without that Fn key.  It really bothers me (in terms of muscle memory for keyboard shortcuts), since it means Control is no longer on the very bottom left!  I think I’d be a lot happier if they put Fn key on the right side of the spacebar.

image

« Prev - Next »