Saturday, December 22, 2012

Threads and Exceptions

I learned something recently. One should be careful with catch(...). And one should be very careful with pthread_cancel.

The catch-all has a limited uses of course, since you usually know the types of exception to expect. However, there is the rare occasion for its use. What I learned is that you must always re-throw the caught exception. If you don't, pthread_cancel and pthread_exit may break.

The reason is that on Linux, those functions work by throwing a special exception. This exception is special and does not derive from std::exception. You must re-throw it. It is possible to catch this exception alone and re-throw. In order to do that, see this post.

The same logic also implies that when using pthread_cancel, you should not use functions which serve as cancellation points in destructors. In other words, it is best not to use pthread_cancel.

In summary:

  • When using catch(...), always re-throw.
  • Do not use pthread_cancel.

Note: the same does not appear to be true on Solaris.

References: Ulrich Drepper's blogKenneth's blog.

Monday, December 3, 2012

runonce

I sometimes need a process running in the background. Long ago, I wrote a very simple script which runs a command if not already running. Now, it's updated for OS/X.

https://github.com/jeffgarrett/scripts/blob/master/runonce

Sunday, December 2, 2012

MathJax for Blogger

For basic MathJax support in Blogger, all you have to do is edit the HTML of your template and put the following before </head>:
<script type='text/x-mathjax-config'>
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']],
                     displayMath: [['\\[','\\]'], ['$$','$$']]}});
</script>
<script src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' type='text/javascript'>
</script>
This is all you have to do if you aren't using Blogger's dynamic views. The principal issue with this method is that RSS readers do not render the LaTeX. This was the justification for the LaTeX for Blogger user script. But MathJax looks so much better on a retina screen!

It is possible to have the best of both worlds, and maybe one day I'll blog how...
$$\int_0^1 x^2 dx = \frac{1}{3}$$ Source: checkmyworking.com

Edit: Set your mobile template to "Custom" to pick up the MathJax on mobile.

Friday, November 30, 2012

New MacBook Suggestions

So I have a new MacBook. It's my first and only Apple product. Any suggestions?

I'm looking for a good terminal app and a good tiling window manager (a la i3). Also, is there a way to maximize windows without making them full-screen?

Wednesday, November 21, 2012

Battery Life Answer?

I may have found an answer to my question. My battery life is back over 24 hours. Investigation suggested that it was syncing-related. I tried the following two things (after other failed attempts) based on the weak evidence I had:
  1. Set my phone to always keep wi-fi on during sleep (under Wi-Fi, under Advanced in the menu). I have weak cellular coverage in my house, so falling back to cellular isn't necessarily better for battery.
  2. Disable Currents from syncing. It is a heavy abuser, and I don't use it.
Problem solved.

By the way, two apps I have used for keeping an eye on battery are BetterBatteryStats (good for investigation) and Battery Widget? Reborn! Pro (general purpose, good for keeping an eye on drain).

Thursday, November 15, 2012

Android 4.2 Battery Life?

My Galaxy Nexus' battery life has gone from about 25 hours on 4.1 to 8 hours on 4.2. The same is not true of my Nexus 7.

I haven't figured out what it could be. Any ideas?

Wednesday, November 14, 2012

Android Update Trick

Android 4.2 is rolling out to Galaxy Nexus and Nexus 7 devices. If you're impatient, there's a trick which worked for me:
  • Go to Settings
  • Disable Wifi
  • Go to Apps, then to All
  • Find Google Services Framework
  • Force Stop
  • Clear Data
  • Go back to Settings
  • Enable Wifi
  • Go to About phone/tablet
  • Go to System updates
  • Check now
Your mileage may vary.

Source: Gotta Be Mobile

Monday, October 29, 2012

Nexus Announcements

Google canceled the Android event today due to the hurricane, but the expected products were still announced. Take a gander.

Nexus 4

A new phone, the Nexus 7 was announced. The specs are below, with comparison to the previous Nexus and the recently announced iPhone 5. Most interestingly, it will support wireless charging.

Nexus 4Galaxy Nexus (GSM)iPhone 5
ProcessorQuad-core 1.5GHzDual-core 1.2GHzDual-core 1.3GHz
Display4.7" 320ppi4.65" 316ppi4" 326ppi
Camera8MP5MP8MP
Wireless chargingYesNoNo
NFCYesYesNo
Operating systemAndroid 4.2Android 4.1iOS 6
Battery2100mAh
15.3hr talk
390hr standby
1750 mAh1440mAh
8hr talk
225hr standby
Price$300 (8G), $350 (16G)
Subsidized: $200 and up
$350 (discontinued)$649 (16G), $749 (32G), $849 (64G)
Subsidized: $200 and up

Nexus 7

The pricing of the Nexus 7 has been reduced. Formerly, the 8G version was $200 and the 16G version was $250. Now, the 8G version is discontinued, the 16G version is $200 and the 32G version is $250. Also, a version with 32G and HSPA+ data will be released on November 13 for $300.

Nexus 10

A new Nexus 10-inch tablet with an extremely high resolution amazing display was announced. The Nexus 10 is 300ppi. For comparison, the iPad 3 and 4 are 264ppi. The Nexus 10 will be available for $400 (16G) and $500 (32G) on November 13.

Android 4.2

An incremental version update to Android, still called Jelly Bean, accompanies the devices. As expected, it will support multiple users (on tablets). This could be an important feature for shared tablets.

Google Now

Android 4.2 comes with an update to Google Now which adds flight information, restaurant and hotel reservations, and shipping details.

Photo Sphere

Android has had panoramic photos for some time, but now that Apple has it, I guess it's time for something new. This new feature produces StreetView-inspired 360-degree immersive experiences, shareable on Google+ and Google Maps. This is potentially interesting.

Gesture Typing

Android 4.2 also includes Gesture Typing, which sounds like direct competition with Swype, and now SwiftKey Flow.

Google Music

The announcement included unexpected updates to the Google Music service. First, they will have a matching service. Apple was first with iTunes Match, and then Amazon with their Cloud match (both $25/year), and now Google comes along with their matching service (free). The benefit is that music files can be matched against the content library and users can access music they legally own without having to upload it all. For people with large mp3 libraries, this is a much quicker way to get started with online music. The matching service will come to Europe first on November 13. Google also announced a partnership with Warner Music Group, the major label holding out from listing on Google Music.

Source: Google

Saturday, October 6, 2012

Funny!

Bing is aggressively advertising their Bing It On challenge, the "Side-By-Side Search Off." So what do you get if you search for "side by side search off"? Here's Google. Here's Bing.


Google has Bing's challenge page as the first link. Bing doesn't even have it on the first page! Challenge lost.

Wednesday, September 5, 2012

Everything is Relative

A Hulu commercial for IE9 shows a number of flattering quotes, including "IE9 is amazingly fast," from no less than the New York Times. That doesn't seem right.

A search suggests this quote came from a September 2010 blog article, "Microsoft's New Browser Is Pretty Cool. No, Seriously." The context of the quote is awesome (emphasis added):
First and foremost, IE9 is amazingly fast. Past versions of Internet Explorer always seemed bloated and slow, especially compared to Google‘s Chrome. But I’ve been using both for a week, and Microsoft’s browser keeps up with Chrome on my PC. (Full disclosure: Microsoft lent me an up-to-date laptop that shows off IE9 better than the bargain-priced netbook I usually work on.) 
 And this is what they chose for the commercial!

Thursday, June 14, 2012

Tips for Google: Southwest in Flight Search

Google's flight search could be useful. But, sadly, they don't have my prices for Southwest Airlines. Something must be done!

I can speculate a few reasons SWA excludes itself from other agencies or sites, and chooses to sell exclusively on their own website:
  • It may cost money to be in those systems, either explicitly through fees or implicitly through added overhead due to commissions.
  • Southwest might lose its reputation as a low-cost carrier if its fares were shown side-by-side with other carriers.
Regarding the first point, Google doesn't need the fee revenue, and including SWA in the search results will drive more traffic to SWA's own website. There is precedent. SWA lists fares both on Travelport and Expedia's Egencia. Comparison-shopping is ok for corporate travel, but not regular consumers?

Regarding the second point, in my personal experience, Southwest's fares are definitely more expensive than competitors', to the tune of about 25%. But SWA is more customer-friendly. It is much better not being hit with fees for every little thing. Flying American? Want to check a bag? Fee. Want to switch flights? Fee. Want to cancel your reservation? Fee. Want to redeem a rewards ticket without enough notice? Fee.

You pay more for Southwest's flexibility. Is it worth it? Probably.

Maybe it doesn't make sense to allow "ordinary" people to comparison shop if they lose their reputation for being cheap. If big G really wanted to list SWA prices I can imagine, say, only listing their prices on pages where you also show the competitors' fares with one checked bag included while also listing the base fare. That seems fair, pun intended.

Wednesday, June 13, 2012

Tips for Google: Blogger Configurable Ad Formats

Blogger rolled out dynamic views some time ago. They provide a really nice, modern interface.

But, as far as I can tell, dynamic views ignore ad format settings, being able to choose the type and size of the ads. I absolutely hate flash ads, and if I can't prevent them, I'll just remove ads altogether.

Tuesday, June 12, 2012

Tips for Google: Blogger Scheduled Sharing

Blogger supports sharing to Google+ from the list of posts. Blogger also supports this wonderful feature of scheduling posts. But you can't share a post until it is public.

Wouldn't it be nice if you could share scheduled posts, meaning that when they become public, they will also be automatically shared to Google+?

Monday, June 11, 2012

Tips for Google: Drive Archive Support

To start posting more regularly, I'll start a series on small pet peeves with Google products.

Let's start with Google Drive. Google Drive can support archive file formats but only zip and rar according to the support page.

It should therefore be easy to add support for more archive formats, but notably missing are tar-based formats. Why not include uncompressed tar, and tar compressed with gzip, bzip2, and xz?

Finally, I end with two questions whose answers are not obvious: does Drive's search functionality extend to documents included in an archive? And, can archives within archives be viewed as easily?

Tuesday, May 1, 2012

Ally Bank App!

Ally Bank has released Android and iOS apps. Ally alluded to this earlier in the year with a modification of their deposit agreement. The Android app functionality is limited to checking balances and making transfers currently.

Go get the app: Ally Mobile Banking

Friday, April 27, 2012

Google Search: More by Author

I didn't notice this announced, but Google quietly added "more by" links to search results. It will find all results associated with the same author. Here's my search results. What I found very interesting is that Google found articles written by me long ago and which, as far as I know, were never associated with my current email address, or any email address listed on my Google profile. Now, that's clever!

Wednesday, April 4, 2012

Samsung Vibrant with ICS!

Remember when I rooted my Vibrant? Just recently CyanogenMod 9 (based on ICS) nightlies started being built for the Vibrant, so there's no better time to go ahead and jump up to bleeding edge CM9, right?

My only concern was jumping from the Bionix-v ROM to CM9. I have heard some horror stories when switching between custom ROM series. So just to be safer, I went through the CM7.2-rc1 release candidate as an intermediate step.

It was fairly painless. Of course, always start with a backup. I highly recommend Titanium Backup for apps and SMS Backup+ for SMS and call logs, though given my use of Google Voice the latter is not as important. Titanium can upload to Dropbox which is a bit of insurance against the worst case. I temporarily disabled two-factor authentication on my accounts where I use Google Authenticator as a second factor, so as to not lock me out if I bricked my phone. :) All my Google data is synced into the cloud. Finally, I also highly recommend Xmarks for bookmark syncing between all devices. Because of that, my bookmarks are also all safe in the cloud. Just one last sync, and that was it.

Then came the fun part! I downloaded CM7.2-rc1 from the link on the CM wiki. I used ClockworkMod ROM manager to download the Google apps package. I booted into recovery to install. And then, uh, it got in a loop constantly rebooting. Pull out the battery to stop the loop and boot again. :) Just to be a little more sure of the state, I used the "install zip from sdcard" option to again install CM7.2-rc1 and the Google apps. Reboot and... Android 2.3!

That was simple enough I then downloaded the CM9 nightly and Google apps package again, and used "install zip from sdcard" in the recovery. I had no issues, and a few reboots later I have Android 4.0!

I'm having fun in ICS. It is chewing through the battery though.

YMMV, of course. Happy flashing!

Tuesday, February 21, 2012

LaTeX User Script Updates

I posted a minor update to the LaTeX for Blogger user script to fix it in Blogger's new editor.


\int_0^1 x^2 dx = \frac{1}{3}

Sunday, February 5, 2012

Southwest In-flight Wifi


Posted from somewhere over the Midwest.