Setting Up Octopress on Windows 7 a.k.a. - Ruby Gems Involved? Run From Windows!

| Comments

Short version - don’t. Sooner or later - shit won’t work. Windows and Ruby and Gems are just not meant to be together (unless it’s Windows running VM running Linux) [instructions below].

I’ve bought a MacBook Pro circa 2 years ago and I’ve been very happy with it in the beginning. I started learning *ix operating system, felt the power of the command line, used plenty of nifty little tools, tried Ruby, done some Rails and it’s been great every step on the way. No problems installing new software, no bloat-ware weighting hundreds and hundreds of megabytes. I’ve proudly run my blog on Octopress and been thinking it’s awesome.

But recently I’ve noticed something really funny (can’t believe took me that long to realize) - I’m using Windows on my Mac, booting to Mac OS X only when I need to write a post for my blog (which in turn is stupid as I mostly blog about C# when writing about code). Separate post coming up on Mac vs Windows PC from the perspective of (mostly) .NET developer. So, here’s how to setup Octopress to work on your Windows 7 machine:

  • Download VMWare Player, it’s free
  • Download Ubuntu 12.04 LTE, also free
  • Unzip file downloaded in step 2, In VMWare Player - open Virtual Machine from the location where you unzipped into
  • Boot the machine and install VMWare Tools (Ubuntu will ask about that upon first boot)
  • Go to Settings -> Displays - and change the resolution (most likely on your machine by default Ubuntu runs in funny small window)
  • Open ‘Terminal’ and switch to ‘admin’ user, default password is ‘password’ (assuming you’ve downloaded image recommended in step 2)
  • run
1
apt-get install git
  • run
1
apt-get install ruby1.9.3
  • run (last ‘octopress’ can be changed to your liking)
1
git clone git://github.com/imathis/octopress.git octopress
  • Enter the folder where you have cloned octopress
  • run
1
gem install bundler
  • run
1
bundle install
  • run
1
rake watch
  • open another terminal window and run
1
rake preview
  • go to
1
http://localhost:4000

Voila! PS. This post has been created on Ubuntu Linux running as a virtual machine under Windows 7 x64 and has just been deployed on Heroku (more on this in the next posts).

Lumia 920 Review

| Comments

For a few weeks I have been using a white Nokia Lumia 920 as my main phone. TL;DR version is I didn’t like it.

I am really picky about the smartphones I choose to use on daily basis and I have used quite a few, starting with original iPhone just a week or so after its debut and ending up with Samsung Galaxy S III (which btw I think I’m going to replace with my old iPhone 4S). To give you the context for what was important to me and what I took into account when rating Lumia 920, here’s a list of what I need from my mobile phone (both hardware and software):

Setup Mono for Android on Windows - Tutorial

| Comments

After a short (3 weeks) adventure with Windows 8 I’ve decided I don’t want to struggle with the system (nor constantly switch back to ‘Desktop’ mode after another accidental switch to ‘no-longer-called-Metro-UI’) and so I came back to well known, liked, cozy Windows 7 x64. This is the system I’ve been using at work for a little more than last 3 years (basically since day one it RTM-ed) and the one I split time when developing at home - 50/50 with Mac OS X. I’m a convert from iOS church to the Android - the mobile OS that brought me to my knees with Samsung’s Galaxy S III (I’ll post about it on another occasion). And so I wanted to get at least a little bit familiar with developing for Android, however I wasn’t that much enthusiastic when I thought about a perspective of switching development environment to Eclipse and programming language I use on daily basis to Java. Fortunately Xamarin offers the tooling that allows developers to develop for Android (as well as iOS and Mac) using C# and Visual Studio (as an option).

Note: The best thing you can do is to head over to Xamarin - trials and after registering - run the setup. Mono for Android installer should automatically detect which of the prerequisites are missing from your system. However in my case (and as Google search results show I’m not the only one) - this didn’t work. Also - you need to have a paid version of Visual Studio (Express edition won’t suffice as it does not support 3rd party extensions). I also think - following step-by-step guide gives you a better understanding of the pieces of the puzzles involved, than clicking ‘next’ a few times in the installer

So here are the steps required to configure Mono for Android on Windows, with Visual Studio, to enable developing for Android mobile devices in C#:

  • Download Java Software Development Kit 6 Java SDK 6 - do NOT pick x64 version (even if you are on x64 version of Windows), go for x86 version. Also for Mono for Android 4.2.5 - that’s the one I’ve been using - Java SDK 6 is required (it won’t work with JDK 7 - although you can have both installed on your system side-by-side)
  • Download Android SDK - click on the ‘Download SDK Tools for Windows’ (ADT Bundle includes Eclipse, which is not the option I wanted to go for)
  • After Android SDK is installed Android SDK Manager will run. This allows installing different APIs (these depend on the Android version you would like to target). In my case I went for API 16 (Android 4.1.2), SDK tools, Android device emulator. Pick what you see fit.
  • Now it’s time to configure your AVD (Android Virtual Device) Choosing AVD option from Android SDK Manager menu

This is the emulator that will simulate a real physical device, when you will be testing your application written in C#, with Mono for Android (to deploy to real device you need to buy a licensed version from Xamarin). There are many different Android devices in the wild, differing in screen size, screen resolution, hardware capabilities, memory size, etc… The best way to setup AVD as so its configuration would reassemble a real device is to do a Google Search e.g. for ‘Android AVD configuration for Galaxy S III’. One thing to note here is that what is important is screen’s resolution, API version - which may vary, depending on which Android version you have installed on your handset. So for example for Galaxy S III bought in Poland in 2012 - 90% you’d get a 4.0 (Android Ice Cream Sandwich). However my handset has a custom ROM installed, which is based on the latest 4.1.2 (Android Jelly-Bean) and so I’d pick API16 rather than API15. You can check the version of the ROM (Android) installed on your phone by going to Settings->About device and checking value on ‘Android version’. So - the information Googled + info about your phone will tell you everything you need to know to successfully setup your AVD. First, switch to ‘Device definitions’ tab and then click ‘New device’ button. Set it up like so: Geekbeing's new device - Galaxy S III Next, based on this device - create your AVD, mine looks like that (Note: if later on, when trying to run your application on AVD - when it fails - change RAM size from 1024MB to 512MB - I haven’t figured out why, but it seems like AVD is unable to boot when setup with more memory than 512MB - and Visual Studio fails silently - waiting forever for Virtual Device to boot up):

Geekbeing's choice for Galaxy S III AVD

After everything has been installed, you can now run Visual Studio and verify whether everything’s setup properly. Begin your adventure by clicking File -> New Project and configure it like so: Geekbeing - new project, new adventure After the project has been created hit ctrl+shift+b to build the solution. If everything is installed and properly configured, you should end up with an output log similar to this one: Geekbeing - merry output log

Here are some materials to get you started: Mono for Android Tutorials and Guides for free, or should you prefer the book and have some dime to spend - Professional Android Programming with Mono for Android and .NET/C#, happy coding!

JavaScript Tutorial, Part 3 - Dev Setup, Tooling, Learning Resources

| Comments

Note: next three paragraphs are mainly targeted at the less experienced programmers/software engineers. And a few things here and there in the next paragraphs too.

Market for software tools (both paid and free) is huge nowadays and so there are plenty of options to go for. In my mind picking a tool is like picking a dish in a restaurant - unless you’re going for something super-exotic in a cuisine you’re entirely not familiar with and advice from someone experienced might be an option to consider - it should be entirely up to you what you’re going to pick from the menu (and decide how you would like to have it done). And so it may take a few trials, errors and course corrections before you pick something. I believe this step is very important and although you should go and do your research (reading the posts/reviews/comparing features) - there is no better way to find out what suits you and your style than checking out a few options, gaining hands-on experience.

JavaScript Tutorial, Part 2 - Functions and Closures

| Comments

As famous Douglas Crockford (JavaScript guru) noticed functions in JavaScript are the best thing in JavaScript language. In the beginning of your JavaScript journey you will be most likely using functions not to repeat the same code over and over again - so basically to encapsulate a behavior. For example:

Multiplying function
1
2
3
var multiply = function(a, b) {
        return a*b;
    }

A few things to notice here:

  • Function multiply does not have a name, such function is called anonymous. However it can be invoked, because we have a handle to it - variable multiply
  • Function can be assigned to a variable, just like any of the objects in JavaScript
  • There is no type declaration for the parameters a and b. What is more - there is no type checking when you’re invoking the function. Of course - depending on the body of the method (everything between curly brackets) it might or might not work depending on the type of the parameter passed
  • If during function invocation you pass less parameters than it is stated in the definition, like so:
Multiplying function
1
multiply(1);

it’s not going to end with an error. Parameter b will be assigned value of undefined and whole result will also be undefined.