Tuesday, June 24, 2014

Creative Programming for Digital Media & Mobile Apps on Coursera

I just wanted to let you know that another interesting course is starting today on Coursera - Creative Programming for Digital Media and Mobile Apps. I've just gone through the first week of video lessons and they are quite cool. They feature Processing - a development environment for visual arts and various creative projects. It's basically Java with a convenient library of functions that let you write graphic applications much faster. What is great about it is that it lets you export your projects as JavaScript or Android code, so you can easily run them on mobile devices (including iPods and iPads). I used Processing in the past and I quite liked its simplicity and power, although debugging was somewhat difficult.

Using the occasion, I'd like to present to you a site that inspired me a couple years ago to play with computational graphics and various visual effects: Complexification. Although it seems discontinued, you can still find there lots of awesome yet simple pieces of computational art... and the source code is mostly available as well (everything is written in no other than Processing again).

My firts Android live wallpaper has been inspired by the Binary Ring effect from Complexification. Later on, I created another one - Blender, which was based on a submission to the Processing's Exhibition section. It was all before I discovered that live wallpapers were extremely difficult to monetize (especially after notification ads have been banned by Google) and that people didn't download them almost at all, despite being advertised on sites like LiveWallpapers.org...

If you browse through the exhibition archives some more, you'll find plenty of mind-blowing ideas like Mycelium or Shadow Monsters. I've been trying to code up something as awesome ever since I discovered them, but never with much success. Nonetheless, I had a chance to experiment with fractals (Mandelbrot Set rules) and decomposing images into single-colored rectangles, which resulted in a pretty neat effect as well. Hell, at some point I even decided to give my whole family huge prints of computational art interpretations of their photographs for Christmas. How geeky is that!

But I got excited again, so let's come back to the main subject for a while longer. Sign up for the Coursera course, if you haven't done it already, because it's cool, educating and doesn't cost you a dime. If you come up with a Processing app that you'd like sharing with the rest of the people here, feel free to post it in the comments section. I'd be happy to give it a try. Perhaps I'll manage to create something worth mentioning as well...

Thursday, June 19, 2014

Transforming SVG images into Android Drawables

Today I'd like to share with you a technique I used to create my map apps. I've never heard of anyone using it before, even though I find it quite simple. It lets you use SVG images inside your Android apps without any external libraries or extra code. What is more, the images obtained this way load instantly and can be magnified indefinitely without any loss of quality. Sounds interesting? Keep on reading to find out how it actually works.

It all began with my frustration with bitmaps, which caused OutOfMemoryErrors when used in too high resolution or zoomed in too much. I decided to switch to vector images, which unfortunately are not supported out of the box by Android. You have to use SVG parsing libraries that sometimes do not support certain features (text, gradients, symbols), contain bugs, and take a couple of seconds to create a medium-sized image.

After some time an idea came to me - what if I transformed an SVG loading library so that it printed Java code instead of executing it and returning a Drawable instance? It sounded very easy and turned out to require much more work than I initially expected, but the final result was great. All I needed to do was take the printed Java code and paste it inside a new class.

If it still sounds a little abstract to you, I created a sample app that uses an image generated this way. It basically just shows a vector-based creature and lets you magnify it up to 16 times (see the screenshots on the right). You can download it for free from Google Play and test it yourself. I'm making its full source code available as well, so feel free to take a look at it.

If you're wondering what kind of apps you could create using vector images, go and see my Milan Metro. It's a great example of simplicity and performance (just compare it with other similar apps!).

Apart from that, vector graphics is great for UI elements, because it scales without losing quality on all devices and screen densities. There is no need to create separate versions of resources for mdpi, hdpi, xhdpi, xxhdpi, etc.

Another good example I can think of are splash screens. What if you could make sure that they look pretty, regardless of the screen resolution and size, taking much less space at the same time? Wouldn't that be awesome?!

If you'd like to have your SVG pictures transformed into Drawables, check out my Fiverr gig - I can do it for you. You can also contact me via email (bartas [dot] wesolowski [at] gmail [dot] com) if you have a bigger task for me or if you want more instructions on how to implement a similar thing yourself.

Sunday, June 8, 2014

How I didn't get a job at Google

About 2 months ago I got an email asking me if I'd be interested in working for Google. Without much thinking I replied "hell yes", or something of this meaning. They were supposed to call me in a couple of days to discuss the whole procedure. In fact, being quite absent minded at times, I totally forgot about it, and you can imagine my surprise when during my dinner I got an international call from a guy explaining to me how the hiring process works, and then asking me questions about asymptotic complexity. Fortunately, my answers, although somewhat chaotic, seemed to satisfy my interlocutor. We scheduled another interview, also on the phone, but this time involving solving problems and writing code online. I was given four weeks to refresh my knowledge of algorithms.

At that point I decided to get some outside help. I contacted a friend who works for Google in the USA. She suggested that I should go through the MIT Algorithms course and familiarize myself with The Algorithms Design Manual. I started with the video course, since it seemed to me easier to chew up (how wrong I was at that time!). I watched almost 40h of material, took tons of notes and did extensive research online on some of the techniques I didn't quite understand. I didn't have time to event touch the book, but I was putting trust in the MIT professors and their extraordinary teaching skills.

Four weeks passed in a blink of an eye, and so came the day of the interview. I wasn't sure what problem difficulty to expect but I was about to find out. To my bewilderment, the task was actually quite simple. I had to write a Java method building a team ranking chart based on the match results given in a specific format. I breathed with relief, but I still made some small mistakes (fortunately I was able to detect them fairly fast). I didn't even think that they were judging not just my coding skills but also the way I approached the problem and tested my solution. All in all, I got through again and got accepted for an on-site interview. Things were getting really serious.

I had another four weeks to prepare for the next step. I finally coped with the algorithms book, which was great and I recommend it to all of you. I solved 69 problems on Timus (a Russian online judge, which I like). I took part in one online coaching session organized by Google (although I was very late for it because the person who organized it gave me a wrong hour). I studied the official guides telling you how to prepare for a Google interview. I found another helpful book- Cracking the Coding Interview, which was a great source of possible questions and tips for coping with them. In the end, I felt as prepared as I possibly could be.

The interview itself took place in Cracow (Poland) and was composed of five sessions (each with different person) and a lunch (not being evaluated by them). They paid for my plane tickets from Milan and booked me a 4-star hotel (only one night though, the second night I stayed with a friend in a 4-person room :)). Obviously, I didn't sleep very well because I was nervous as hell. I couldn't wait to finally get the burden off my chest, no matter the result. I arrived at the Market Square, where the company's seat is, feeling rather shitty, and trying to make myself think about more pleasant things.

The five sessions went actually quite well. I never had a major glitch. I managed to get out of difficult situations (e.g. when I didn't know the exact method signatures or class names) by going around them in a fairly elegant way. This time I was very aware that they were judging my approach and testing capabilities as well, so even when they were asking me about something simple, I tried to be as thorough as I possibly could. At lunch, I had a pleasant chit-chat with a guy who was telling me about his work (even going into details, which I was quite surprised to hear). Eventually, I let him eat because he didn't have a chance to touch his food when I was already half through mine.

When I left the building I felt such a release that I can't really describe it with words. The world was suddenly beautiful again, the sun was shining, and the ice cream tasted great. I half-convinced myself that I would get the job, because I was happy about my performance. I honestly couldn't think of anything I could have done better, bearing in mind all my preparation. Now, I just had to wait for my recruiter to call me (she went on vacations for two weeks, so I knew it would be in some time).

Three days ago, when I was on a train, I got the actual call. She told me that unfortunately she didn't have any good news for me. I was not accepted. She assured me that they usually give extensive feedback, but in my case she simply had nothing to say. She suggested trying again next year. Then she hung up.

I probably don't have to tell you that I felt terribly sad, not only because I didn't get the job all programmers dream about, but also because I commited so much of my time to preparing myself. Telling my friends about it, while they were expecting from you to be a genius, was not an easy task as well. I think I'm getting over it now, although I still feel a little nostalgic. We'll see what the future will bring for me instead.

When I come to think of it now, I'm not even sure if Google would be the best place for me. Of course, they have great working conditions and let you be part of a solution that millions of people use every day. However, they are still a big corporation with all its disadvantages - there are people above you who decide what's to be done and in what way, and you're just a cog in a big machine.

For all of you who'd like to give Google a try as well, you can apply here:
Just bear in mind that you'll have to commit quite a lot of your time for preparations, and that perhaps it's not exactly the thing that you would like to be doing (maybe you like mobile apps like me). Anyway, I hope you enjoyed my story, and should you ever go through the whole process, I wish you more luck than I had.