Showing posts from May, 2013

Using Vim on Mac OS - basic settings

In every programmers life comes a moment when they need to deal with Vim somehow - some people just need to close it once accidentally opened, some people need to start using it for work. For a long while I could get away without using it but then I had to start editing Octave scripts and a simple notepad did not seem to be too useful to do that. Ancient roots Vim was released 21 years ago so most of us can argue that is is an ancient editor. An editor from an era where even Java wasn't invented (it was released in 1995). This reason alone could invalidate its usage as so many things changed since then. Well, the thing may not be that different. We are still using some kind of text editors to write source code and the problems around code writing are roughly the same: quickly edit and reformat specially formatted texts. From the first look Vim is an editor that does not even support mouse and even deleting a line is troublesome - not to mention exiting the editor. However

ReSharper free alternative

For a while I was using ReSharper but soon I had to find out that the price and performance of the tool just does not compensate for the features it provides. On a larger solution it just got slower and slower and even though the performance was kind of acceptable it just did not feel right. So I decided to find free alternatives for ReSharper, especially for features that I was really using: quickly jump to files, coloured tabs and organising the 'using' sections. Quickly opening files Probably the most frequently used feature of ReSharper (or at least for me) is to quickly open a file by its name. There are several free plugins that can help you with this but PhatStudio was the fastest and most convenient to use. Simply pressing ALT+O will bring up the dialog and ready to start typing fragments you are looking for: " cu or " for instance would find " CustomerOrder.cs " file. No need for fancy wildcarding, the authors got it perfect. Thanks for this f

Count the 1 bits in an integer – interview question and branch predictor crash course

One of the typical computer science interview questions is to count the “1” bits in an integer. There are many solutions but which one is more practical or faster? A crash course on branch predictors. Let's say the integer we want to count the "1" bits in is: 698 (decimal) In this case the binary representation is: 0010 1011 1010 (binary) so the answer is: 6 Let’s look at three simple implementations and try to guess which one would be faster and why: (note: the code is in Java and the >>> operator is the unsigned shift. It’s usually just >> in other languages). Solution #1 – count to fixed size int cnt = 0; long l = getLongToCount(); int bits = 64; for (int k = 0; k < bits; k++) { cnt += l & 1; l >>>= 1; } Solution #2 – count while non zero int cnt = 0; long l = getLongToCount(); while (l != 0) { cnt += l & 1; l >>>= 1; } Solution #3 – count while non zero and add 1 only int cnt = 0; long l = getLo

Javascript unit tests with QUnit, PhantomJS, driven by Ant

The project I’m currently working on ( ) is fairly Javascript heavy so it was essential to have at least some core functionalities unit tested before they can be submitted to the repository. Running Javascript unit tests in the browser and relying on developers really doing it before submitting code may not be the best idea – they might be in a hurry, or even worse, can get a bit lazy. Let’s see how to make the Javascript unit testing part of the build process. Javascript unit testing There are a lot of different frameworks for Javascript unit testing, so as long as we are not changing the syntax radically of the testing between Java/C#/Javascript, Javascript unit testing will be as normal as testing compiled code. However, some of the frameworks use a very different way of testing: describe("Package X", function() {   it("really should be true", function() {     expect(true).toBe(true);   }); }); Even though the syntax is entertaining to

How to deploy an app to iTunes Store - for iPhone and iPad

I don't publish too many iOS apps so by the time I have to distribute a new one I've already forgotten what the exact steps were. Unfortunately the Android Store (Play) and iTunes store uses quite a different approach, so this is partly a note to self how to do it next time: Create your app in iTunes Connect , add description and  images. Status should be Waiting for Upload. Create a new Provisioning Profile for Distribution , download and import into iTunes (just click it) /note: you already had to have a provisioning profile for development but now you need an another one for publishing the app./ In Xcode project settings (Target, Build Settings), search for "code signing" and set the all signing to your new profile, the distribution profile. /note: an app that is signed for distribution cannot be run on emulator and vice versa./ Chose Product/Archive, which will build your app distribution package Open Organizer (Window/Organizer), and click Validate on