Mandelbrot in Android and C#

Recently I uploaded some old-ish code to GitHub for displaying the Mandelbrot set in Android and in C#. Creating an interactive Mandelbrot explorer application (with pan and zoom) is one of my favorite ways of learning to develop for an unfamiliar platform, since it exercises many of the facets that are common between all platforms, such as rudimentary GUI design (with touch gestures, if possible), basic graphics programming, and optimizing for performance. Although I’m no longer a novice in either Android or C#, this code might still be relevant today. I’ve also gone through and modernized some of it, so that it doesn’t look too embarrassing. Here’s the source code for the Android app, and the source code for the C# application for Windows Forms (.NET). Feel free to check it out and fork!

In the Android code, some emphasis is placed on using JNI, so that the Mandelbrot fractal is rendered in native code to maximize speed, and also uses the native Bitmap API to directly manipulate the bitmap pixels. The C# code, on the other hand, renders the fractal in pure C# (not native code), but it does also manipulate the bitmap pixels directly by marshalling the bitmap to an integer array. Both versions of the code make use of multiple threads.

The C# application also allows you to select the way that the Mandelbrot is calculated. By default it uses simple double-precision floating point, which allows the fastest calculation and therefore lets you maximize the number of iterations for your exploration of the fractal. However, you may also set the calculation to use GMP arbitrary-precision numbers which, while being much slower than double-precision, allow you to zoom into the fractal by any amount (although the calculation will become slower and slower as you zoom in).

(Note: the Android code is now available as an app on the Google Play Store!)




Share this article:
  • Facebook
  • LinkedIn
  • Reddit
  • Twitter

View 3D MPO photos with Google Cardboard

One thing that I’ve been meaning to get my hands on is Google Cardboard, which is an extraordinary bit of technology that transforms your smartphone into a virtual reality display, for the cost of just a few dollars! I love the simplicity of the concept, and I especially like how it repurposes existing features of the mobile device, specifically how it uses the magnetic field sensor to implement a sliding magnetic button. Anyway, I bought mine from Unofficial Cardboard:


While familiarizing myself with the Cardboard SDK, I realized that a perfect application for Cardboard would be to view .MPO photos taken by 3D cameras. So I created a minimal Android app that automatically searches your device for .MPO files, and displays them for viewing with Cardboard!  You can find the app on the Google Play Store, and the source code on GitHub.

A few notes about the app:

  • It automatically searches your phone’s internal memory and external SD card, but only up to two folder levels deep. For best results, place the .MPO files in the root directory of the memory card.
  • It creates a slide show out of all the MPO files that it finds. You may advance through the slide show by using the magnetic Cardboard slider control. It does not currently allow any customization of the slide show (excluding/including files, custom ordering, etc). Stay tuned…
Share this article:
  • Facebook
  • LinkedIn
  • Reddit
  • Twitter

Experimenting with Google’s Project Tango

Recently I had the opportunity to play around with Project Tango from Google:


I whipped up a quick demo, based on the existing sample code from Google, that takes the real-time point cloud provided by the depth sensor and “records” it into a large buffer of points and displays all of it in real time (allowing you to move around a 3D area and record its geometry), and also allows you to save the point cloud to a file, for loading into an application such as Blender.

Here are some screenshots of the demo, after I used it to record the inside of my living room:



Share this article:
  • Facebook
  • LinkedIn
  • Reddit
  • Twitter

Deus ex machina

No dictionary definition of deus ex machina would be complete without a picture of J.R.R. Tolkien’s Eagles. I mean, really. They save the day every single time! When will Gandalf learn to just have them on standby?! Here’s how the stories would go, if the Eagles were used correctly:

The Hobbit: If Gandalf Were Smart

Thorin Oakenshield solicits aid from the wizard Gandalf the Grey to develop a plan to recapture the mountain of Erebor and the vast treasure that lies within it.

Gandalf summons the Eagles and uses them to transport the company of dwarves to the Lonely Mountain. The dwarves proceed to lure the dragon Smaug out of the mountain, and he is promptly torn to shreds by the Eagles, allowing the dwarves to reclaim the treasure that was once theirs.

The Lord of the Rings: If Gandalf Were Smart

Gandalf meets Bilbo at his home in the Shire, and realizes that the magic ring that Bilbo possesses is actually the Ring of Power that is enabling the spirit of Sauron to keep enduring and building a stronghold in Mordor.

Gandalf puts the One Ring into an envelope, then wraps it in several layers of cloth, so that it becomes a bundle that can be easily gripped by an eagle-like creature.

Gandalf summons the Eagles, and puts the bundle into the claws of one of the creatures. He then sends this eagle to Mount Doom, along with the other Eagles for protection against a possible attack by the Nazgûl.

The Eagles make their way to Mount Doom at high altitude, virtually unnoticeable to any ground forces. Once positioned over Mount Doom, the Eagles swoop down, and the one that was carrying the Ring drops it into the lava. Whatever enemy forces were in pursuit of the Eagles are instantly neutralized by the destruction of the Ring, and there’s no further danger.

(Total time to complete the mission: <1 hour.)

Share this article:
  • Facebook
  • LinkedIn
  • Reddit
  • Twitter

A poem by J. Jayson Poryk

Three men doing the work they love,
Three beds unfolding from above.
Inside the Stanton Building did they roam,
And in the public restroom did they make their home.

A quiet life, but not without excitement,
A changeover would bring them all delightment.
Dispensing soap, a paper towel, bowl full of mints,
With care did they conceal all hints
Of the duality of their existence,
But only in this lifestyle could they find subsistence.

O, all the simple pleasures each of them enjoys,
They are, and will forever be, the Bathroom Boys.

Share this article:
  • Facebook
  • LinkedIn
  • Reddit
  • Twitter

A first look at Google Glass

For the last few weeks I’ve been geeking out on Google Glass, which I received after some time on the waiting list. I thought I’d share some firsthand observations and experiences with this marvelous little device.

First, it looks like Google took a lot of lessons from Apple in the design of the product, but especially in the design of the packaging. The box is minimalist and monochrome with a matte finish, with only the logo printed on top in a humbly small font. There’s no plastic anywhere, and therefore no need for a utility knife and the strength of ten men to pry open the package. The inside of the box contains layers of perfectly-shaped cardboard that fit snugly around the curves of the device. It’s enough to make one salivate, an impulse on which Apple has been capitalizing for a while now. But enough about that.

The thing that impressed me the most (at first) was how well Glass fits around my head. I was worried that it would be slipping and wobbling as I move around, but that’s not at all the case. The fit is very comfortable and very stable. I was able to wear it for hours without any discomfort.

The positioning of the see-through display is also very well thought out. It obstructs only a small portion of the field of view, and after wearing it for a while, it becomes hardly noticeable.

I haven’t worn Glass to any restaurants or movie theaters (because I’m not a douche), but I have worn it while exercising, hiking, writing, reading, shopping, cleaning, and playing board games. In each of those instances, Glass contributed positively to the experience, as long as you discount being called a dork by everyone you encounter (although I’m pretty sure I evoke that response regardless of Glass).

The most useful feature to me, so far, has been the ability to read emails right before my eyes, as they come in. A close second is the ability to look things up on the web at any time, using my voice (and the voice recognition is quite good). Being a seasoned Android developer, I’m currently brainstorming possible “apps” that could be developed to enhance the experience even further (ideas are welcome).

So then, is Google Glass another ephemeral fad, or is it the future of wearable computers? There’s no doubt that, at the very least, it’s a powerful demonstration of the potential of today’s technology. Whether this particular implementation of the technology will be widely adopted remains to be seen, as Google still hasn’t set an official release date for the general public.

I think that Glass would be adopted much more readily if it didn’t have the front-facing camera, as useful as it is. Nearly everyone I spoke to while wearing Glass said something like, “You’re not recording this, are you?” There’s definitely some kind of psychological turn-off about having any kind of camera pointed at you. If only Glass came without a camera, and was simply a monitor device for the wearer, it might be much more palatable to the public, and less controversial in the media. But then, who says a little controversy is a bad thing?

Share this article:
  • Facebook
  • LinkedIn
  • Reddit
  • Twitter

Dealing with Google Play Store reviews

Or “How to keep your sanity while being an app publisher”

It has been roughly a year since I’ve published my first significant Android app (DiskDigger), and roughly a month since I’ve published my first paid app (DiskDigger Pro). Over the course of this time, I’ve learned some valuable lessons about human nature, specifically about the nature of the humans that leave star-ratings and write reviews about your app. If you’re a fellow app developer, I hope you’ll commiserate with this post. And if you’re a newcomer to the Google Play Store ecosystem (or the Apple App Store, for that matter), take heart.

Of course, this article assumes that your app actually works, and does what it promises. It assumes that negative reviews are not expected for your app, and come as a surprise to you.

People Will Be People

We’re all familiar with YouTube comments, and the breathtaking stupidity to which the commenters are guaranteed to stoop. Most of this idiocy comes from the fact that the commenters are able to write anonymously (or at least semi-anonymously), which is enough to open the floodgates of ignorance, hatred, bigotry, trolling, and everything else. Much of this mentality translates right over to app reviews.

If you’re an app developer, you will get bad reviews. Get used to it. This is for a very simple reason: there’s a significant imbalance in the activation threshold for writing a good review versus a poor review. In order for someone to give your app a five-star rating, and a good review, they have to be extremely impressed by it. However, in order for someone to give a one-star rating, they only have to find a single wrong thing in the app! Maybe it’s some portion of the interface they find annoying, or some behavior they didn’t expect, etc.

This is fairly similar to reviews of restaurants that we find on Yelp. Most of the positive reviews on Yelp come from people who write reviews as a hobby (who make it a point to write reviews of every place they visit), whereas the negative reviews are from people who happen to catch the wait staff having an off day, and write a review on Yelp when they otherwise wouldn’t.

You Can’t Please Everybody

If you worry about pleasing all of your users, you will burn out. For one thing, if you try implementing everyone’s feature requests, your app will become a disjointed mess, and will likely be used by fewer people than before. Choose very carefully which feature requests to implement, and acknowledge that certain users simply cannot be helped by your app, even if their poor review is constructive.

And another thing: if you try implementing everyone’s feature requests, you will develop feelings of resentment towards your users when they continue to give poor ratings (which they will, for the reasons stated above). You will say, “How dare you rate my app poorly, when I’ve spent so much time implementing features that others have asked for!” These kinds of emotions are highly destructive, and pave the way towards madness.

Don’t Expect Them to Read Instructions

Asking your users to read any kind of instructions prior to using your app is asking too much. Case in point: My DiskDigger app only works with rooted devices. I state this in the app description several times, and very plainly. I also put the word “root” in the title of the app. And yet, there have still been people who wrote a review to the effect of, “When I launch the app, it says I need a rooted device. Why wasn’t I warned about this?” No, I’m not joking. Read the reviews for yourself, if you like.

If your app requires the user to have any kind of a priori information before using the app, be prepared to receive poor ratings from users who weren’t aware of it.

Other Oddities

Some people seem to think that giving a one-star rating is a good way of asking for help. I have received numerous one-star ratings where the user says, “Can someone help root my phone?” or, “Can you implement feature X?” I’m not sure how to deal with such “reviews,” except to shrug my shoulders and move on, since the sight of the one star is enough of a turn-off to not want to help this person to begin with. Also, while it’s possible for them to change their rating after they’ve been helped, the time-to-reward ratio is really not worth it. They’re always welcome to contact me directly, anyway.

On the flip side, other people have written five-star reviews in order to come to my defense against the one-star ratings. While I certainly appreciate these kinds of sentiments (since they balance out the trolls somewhat), I would rather get uniformly honest reviews of the software itself, rather than meta-bickering in the comments.

Responding to Reviews

The Google Play Store allows developers to respond to each review. However, the current mechanism for doing this is deeply flawed, because the responses are posted publicly, underneath each of the reviews!

Furthermore, the responses are limited to 350 characters! This is hardly ever sufficient to thoroughly answer the user’s questions, or guide them towards resolving their issues.

All of this creates a hostile environment, where the developer is encouraged to come down to the same level as the reviewers. That’s not to say that the reviewers aren’t smart, or don’t have legitimate issues or concerns. It simply encourages the developer to become defensive, or even argumentative, towards the users. It’s almost as if Google is saying, “Hey, look what this guy wrote about your app! Are you gonna let him get away with that? Use these 350 characters to stand up for yourself!”

Lastly, the very notion of “responding to reviews” encourages the developer to constantly check the reviews. For a developer who is prone to OCD (like myself), this kind of thing can be very hazardous to one’s mental health! Even now, a part of myself is desperate to log on to my Play Store console, and check for any new activity.

Suggestions to Google

Here are a couple suggestions that would improve the Play Store experience for users, as well as for developers:

Before allowing a user to write a review, ask if the user wants to contact the developer for support! It’s baffling why Google doesn’t display contact and support information for each app much more prominently than it currently does.

If the user selects anything less than five stars, make a text box that slides out and says, “Having issues or any questions regarding this app? Ask the developer for help!”

If that’s too much to ask, then at least allow developers to respond to reviews privately, and directly over email. Responding privately instantly changes the dynamic of the conversation. It also consolidates the number of support venues that the developer has to worry about, since the issue has been moved to email, which should be the primary support venue.

And if that’s too much to ask, then at least notify developers when the user has read the response, as well as when the user updates or amends the rating to which you replied.

Like Water Off a Duck’s Back

Let’s compare app reviews to restaurant reviews one more time. There are several key differences between the two.

A successful, established restaurant might get, say, five reviews on Yelp per week, at the most. Therefore, the manager of the restaurant might do well to read each review (and will have time to do so), to see things like which menu items are trending and which ones aren’t, how the service staff is performing, and so on.

However, a successful app can get dozens of reviews per day. It’s therefore completely impractical for the developer to pay attention to each one. At this point in the app’s lifecycle, it’s more useful to look at the trends of your star-rating (e.g. on a weekly basis). If the rating takes a dive shortly after you publish an update, it might indicate that the update contains a bug, and merits further investigation. (If the app really does contain a bug, you’ll receive messages from users via email, anyway.)

There’s one more crucial difference between app reviews and restaurant reviews. Restaurant reviews are generally written by intelligent adults with a discerning palate. App reviews, however, can be written by anyone in the world, including 13-year-old trolls, 90-year-old senile grandparents, and everyone in between.

If you haven’t guessed this by now, the proper way to deal with negative reviews is to simply let them roll off you, like water off a duck’s back. Most importantly, don’t let them get to you: don’t let them affect your work or break your spirit.  They will always be there; get over it.

Whether or not you make money from writing software, it should at least make you happy. If you find that it isn’t, then you’re doing it wrong. The fact that a single other person wants to use your software should be reward enough. The fact that your app gets occasional negative reviews simply means that your app has reached that level of popularity, and that’s something to celebrate, not fret over.

Share this article:
  • Facebook
  • LinkedIn
  • Reddit
  • Twitter

DiskDigger Pro for Android!

I’m pleased to announce the release of DiskDigger Pro for Android! This new version of DiskDigger is capable of recovering (carving) over 20 different types of files from your Android device’s internal memory, or an external memory card. This includes support for .JPG photos, .MP3 and .WAV audio, .MP4 and .3GP video, raw camera formats, Microsoft Office files (.DOC, .XLS, .PPT), and more!

As with the non-Pro version of DiskDigger for Android, this app requires root privileges on the Android device. The non-Pro version of DiskDigger will remain available (for free!) on the Google Play store, and can still be used for recovering .JPG photos.

So what are you waiting for? Go to the Google Play store on your Android device, and install DiskDigger Pro today!

Share this article:
  • Facebook
  • LinkedIn
  • Reddit
  • Twitter

A new low in SEO scams?

There are honest business models, and dishonest business models. Honest business models include businesses who manufacture useful products and sell them to consumers, or perform a useful service for a reasonable price. Dishonest business models include pyramid schemes (such as Mary Kay and Amway), Ponzi schemes, and alternative medicine.

But there’s also a third category of business models: the bottom of the barrel. These businesses exist almost exclusively on the Internet and, boy, are there a lot of them. These types of businesses include:

  • Selling spamming services
  • Selling botnets to spam more efficiently
  • Pretending to be a charitable organization during a disaster
  • Gaming (exploiting) affiliate programs from web hosts or porn sites
  • Affiliate programs from affiliate programs from web hosts or porn sites
  • Selling e-books about how to sell SEO services
  • Selling e-books about how to game affiliate programs
  • (and the list goes on…)

But now, it looks like a new contender has stepped forward:

  • Translating random web pages in exchange for link placement (resulting in improved search engine rankings)

Before I describe the scheme fully, let me start at the beginning. Last week I received the following email:

Dear Sir,
I am writing to inquire regarding your web page about running in Linux where I have found a lot of useful information. My name is [name redacted] and I’m currently studying at the Faculty of Computer Science in Belgrade. Here is the URL of your article:

I would like to share it with the people from Former Yugoslav Republics: Serbia, Montenegro, Croatia, Slovenia, Macedonia, Bosnia and Herzegovina.

I would be grateful if you could allow me to translate your writing into Serbo-Croatian language, that is used in all Former Yugoslav Republics and to post it on my website. Hopefully, it will help our people to gather some additional knowledge about computing.

I hope to hear from you soon.

[name redacted]
Tel: +381 62 300604

Wow, someone wants to translate one of my pages into another language! What an honor. However, after the initial flattery wore off, I noticed a few things that didn’t seem to add up:

  • The page that this person chose to translate is fairly obscure. It almost seems like it was chosen at random. A native speaker of “Serbo-Croatian” wouldn’t gain anything from it without a lot of background knowledge.
  • A language like Serbo-Croatian is itself fairly obscure. I would guess that a Serbo-Croatian citizen who is remotely interested in “computing” will most likely speak English to begin with, so this kind of translation would be useless.
  • The verbiage in the email sounds a little too boilerplate, with phrases like “a lot of useful information” and “additional knowledge about computing.”

So, what could be this person’s real motive?

If we follow the link in her signature, we see that she is affiliated with “WebHostingGeeks”, which appears to be a web hosting review site that makes money from web host affiliate programs and paid reviews. This certainly makes it a traffic-driven business model, and it therefore has a lot to gain from any kind of SEO “scheme.”

After doing a Google search for “WebHostingGeeks” combined with the name of the person from the email, we see a plethora of results where the scheme repeats itself over and over: dozens of seemingly random web pages translated into Serbo-Croatian, with a link back to the WebHostingGeeks site.

And the pieces fall into place. Here’s how the scheme works:

  • A webmaster receives an email from a foreign-sounding person, asking for permission to translate one of their web pages.
  • The webmaster feels honored, and replies “absolutely!”
  • The translator translates the page (using Google Translate, maybe with a few touch-ups), and asks the webmaster to add a link to the translated page from the original page.
  • The webmaster, blinded by pride, puts a link to the translated page onto the original page (and often blogs about what an honor it is to be noticed in such a remote corner of the world!).
  • Over time, if enough credible web pages add these kinds of links, then the malicious target of the links (i.e. WebHostingGeeks) will climb straight to the top of Google search results, precisely because it’s linked to by oh-so-many respectable sites.

Indeed, after some extensive Googling, it’s surprising just how many very respectable websites have been fooled by this scam. Just do a search for “webhostinggeeks translate serbo-croatian”, and you’ll see for yourself.

“Traditional” SEO schemes have their place among the bottom of the barrel, but this is surely a new low. I actually commend them for almost getting one past me.

I call on all webmasters out there: if you’ve received this kind of offer to translate one of your pages, and added a link to the “translated” version of your page, please remove it, and show the scammers that we’re smarter than them. These shady business practices are mired in obscurity, and that’s where they belong. Please share this information with anyone who may be affected.

Update (Nov. 2013): I’ve been contacted by the person who sent me the original email, and she requested that I remove her name from this post, since it’s been having a negative effect on her online reputation (she is no longer associated with WebHostingGeeks). So then, not only does she appear to be a real person, but she claims that WebHostingGeeks paid her to do these translations by hand (not using Google Translate). Could it really be worth all that trouble just to gain a tiny bit more Google rank?

Share this article:
  • Facebook
  • LinkedIn
  • Reddit
  • Twitter

My BASIC beginnings

Edsger Dijkstra was absolutely right when he said, “Programming in BASIC causes brain damage.”  (Lacking a source for that quote, I found an even better quote that has a source: “It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.”)

When I reflect on my (not-too-distant) programming infancy, I often think about what I might have done differently, like what technologies I could have learned, which ones I should have avoided, or what algorithms I could have used in old software I had written, and so on.

But there’s one thing that really stands out more than anything else:  starting out with BASIC was the worst thing I could have done.

I’m not sure how useful it is to talk about this now, since BASIC has pretty much gone extinct, and rightly so, but it feels good to get it off my chest anyway.

My parents and I immigrated to the U.S. in 1991, when I was 10 years old, and I had never laid eyes on a personal computer before that time. During my family’s first few months in the States, we acquired a 80286 IBM PC, which was probably donated to us by an acquaintance (since the 80386 architecture was already prevalent at that time, and 80486 was the cutting edge).

I also happened to come across a book called BASIC and the Personal Computer by Dwyer and Critchfield.  I was instantly fascinated by the prospect of programming the computer, and the boundless possibilities that computer software could provide.

However, I made a critical error that would hinder my programming development for at least a year:  I reached the erroneous conclusion that BASIC was the only language there was!

I had no idea that BASIC was an interpreted language, or indeed what difference there is between an interpreted and a compiled language.  I thought that all software (including the games I played, Windows 3.0, Word Perfect, etc.) was written in BASIC!  This unfortunately led me down an ill-fated path of self-study, which took an even stronger effort to undo.

I learned all there was to know about BASIC programming in a few months (starting with GW-BASIC, then moving to QuickBASIC), and then I started to notice certain things about the software I was trying to write.

No matter how I tried, I couldn’t make my programs be as fast as other software I used. I couldn’t understand why this was the case.  Also, the graphics routines in BASIC were virtually nonexistent, so I was baffled how anyone could write games with elaborate graphics, scrolling, and responsive controls.  I was eager to start developing games that would rival my favorite games at the time, like Prince of Persia, Crystal Caves, and Commander Keen.  But the graphics and responsiveness of those games was orders of magnitude beyond what I could achieve with my BASIC programs.

With all this frustration on my mind, I was determined to find the reason why my programs were so limited.  I soon found a solution, but once again it was the wrong one!  I stumbled upon some example BASIC code that used assembly language subroutines (encoded as DATA lines in the BASIC program), as well as INTERRUPT routines that took advantage of the underlying DOS and BIOS services.

This led me down the path of learning Intel 286 assembly language (another few months of studying), and encoding it into my BASIC programs!  This solved the issue of responsiveness, but there was still the issue of graphics, or lack thereof.  Fortunately, I found a book at the local public library about VGA graphics programming. Even more fortunately, the book contained sample source code, using a language they called “C“….

And my eyes were open!

It hit me like a freight train. I was lucky that I didn’t have a seizure right there at the library.  I realized that I had been learning the wrong things all along!  (Of course learning assembly language was sort of right, but my application of it was still misguided.)

Learning C and C++ from that point forward wasn’t particularly difficult, but I still feel like it would have been a lot easier if my mind hadn’t been polluted by the programming style and structure that I learned from BASIC.  It makes me wonder how things might have been different, had I accidentally picked up a book on C++ instead of a book on BASIC during my earliest exploits with computers.

In all fairness, I’m sure I learned some rudimentary programming principles from BASIC, but I’m not sure that this redeems BASIC as a learning tool. There were just too many moments where, while learning C++, I thought, “So that’s the way it really works!”  And I’m sure it’s also my fault for trying to learn everything on my own, instead of seeking guidance from someone else who might have told me, “You’re doing it wrong.”

All of this makes me wonder what programming language would be appropriate for teaching today’s generation of young programmers.  Based on my comically tragic experience with BASIC, my gut instinct is to advise aspiring developers to stay away from interpreted languages (such as Python), or at the very least understand that the interpreted language they’re learning is useless for developing actual software. I don’t think there’s any harm in diving right into a compiled language (such as C++), and learning how it hugs the underlying hardware in a way that no interpreted language ever could.

That being said, I don’t wish any of this to reflect negatively on Dwyer and Critchfield’s BASIC and the Personal Computer.  It’s a solid book, and I still own the original copy.  There’s no denying that it was one of the first books that got me interested in programming, and for that I’m thankful.  However, sometimes I regret that I didn’t find Stroustrup’s The C++ Programming Language at the same garage sale as where I found BASIC and the Personal Computer.  Or, alternatively, perhaps Dwyer and Critchfield could have included the following disclaimer in large bold letters: This is not the way actual software is written!  But perhaps it’s time to let it go. I didn’t turn out so bad, right?

Share this article:
  • Facebook
  • LinkedIn
  • Reddit
  • Twitter