Friday, January 27, 2012

IOS-no previous simulator versions!

Ran into a situation today where we had a mobile web app that was reported to be misbehaving on iOS 3.2. The Mac at work has the latest XCode and IOS 5 simulator loaded on it. So we thought it would be quite routine to just start a simulator running IOS 3.2 - after all this having simulators of different versions of the OS is pretty routine. Android makes it trivial and before that, Blackberry has always had different simulator versions for different versions of their OS. Truth be told, RIM probably overdid it. They had too many versions, a developer website that would drive even the most persistent BB fanboys to stark raving madness and documentation that took great pains to suck! Hell, its a separate rant altogether :).


Anyway, after clicking around Xcode for a bit, imagine our surprise when we found that only a device debugging package for iOS 3.2 was available as an updated package for Xcode. That didnt seem right - so off to Google and there's a post on SE http://apple.stackexchange.com/questions/14128/how-do-i-install-the-3-0-iphone-simulator-on-xcode-4


Apparently, Apple doesn't want you to test on previous versions (or atleast - 2 major versions before. Testing on last major version IOS4 is ok though). Now isn't that absolutely ridiculous? Sure, Apple wants people to upgrade their phones to the latest OS versions and they've done a great job of ensuring that later versions of the OS work on older generation phones - but from a development tool standpoint, making tools to test your app unavailable is taking things too far. So tomorrow if my site/app doesnt work properly on a iOS 3 device, the user isnt going to blame Apple. Its the app developer who gets the bug report :(.


So once I'd made my peace with Apple's decisions and diktats on what simulators I was allowed to play with, I reflected on it a bit. I think the key is that that IOS's simulator is really just a simulator (ie software running on the host machine but mimicking a device). On the other hand, the Android emulator is actually a full qnx VM that's totally isolated from the host machine. In IOS's case, the simulator is sharing libraries and tools installed on the base OS - and as such, it would be quite hard to simulate older versions. In Android's case, since each emulator is really like running a VM, you can have all the different versions at your beck and call. On the flip side of things, the emulator approach really slows things down - everything from booting up the VM to actually running code inside it whereas IOS simulator positively zips around. I'm not sure if this is indeed the case - it's just my theory. Looking around on the net, I couldnt find a solid reference - so if you know of one, drop it in the comments.. I did find a few on SE/SO - but they were by no means conclusive http://stackoverflow.com/questions/4544588/difference-between-iphone-simulator-and-android-emulator

VIM macro super powers

So my affair with Vim continues - and I seem to have discovered VIM's macro super powers. The obvious next step is to shout from the rooftops and hence this blog post (and there's hardly anything original - apart from the fact that I've just had a 'aha' moment when it comes to macros and thought it might help other budding vimmers out there...


A little primer - Macros let you repeat a set of commands. The way to go about it is to press q<macro_letter> where <macro_letter> is between lowercase a-z. This starts recording a macro in Vim (and you see a recording message at the bottom). Now hit commands you want to repeat later and press q when done to finish recording. VIM records all the keystrokes you enter in the register you specified as the macro name. To now execute the macro, position the macro on the line and then hit @<macro_letter> and Vim will faithfully replay your commands.


Its a great time saver - especially for complex editing tasks where search/replace doesn't cut it. But, if you're feeling a dissappointed after coming this far (after all, I promised a aha moment), then hang on.


Today's discovery was that you can edit macros that you've recorded quite easily and save them back!!! THIS IS HUGE. Why so? Because when you record a macro, its quite normal to jump around quite a bit or get one or two keystrokes wrong. In fact, its for this reason that I could never use Emacs's macro facility and failed to just 'get it'. However, in VIM, you could just open a scratch pad editor and hit "<macro_letter>p - that's double quote-letter-p to paste the contents of register containing your macro. You see your macro keystrokes - so go ahead and edit them and then use "<register>y<movement> to save your edits back to the register. You can now execute the macro with a @<macro_letter> as if that's the way it was recorded in the first place.


Another obvious tip - you can execute the contents of any register as if it were a macro with a @. Not sure when that could be helpful - but knowing that its possible is good.

Tuesday, January 17, 2012

Yoohooo!! Successfully compiled Android from source

Finally!!!


So my last weekend project had been to compile Android ICS from source. Given that the size of the repo itself is in excess of 6Gigs, just getting it down itself took the better part of Friday night and Saturday night. When I got down to running make on it, it was Sunday afternoon.


Needless to say, things didn't work too well. I'm running this on a 32 bit Ubuntu 10.04 Virtualbox with a piddly 1GB RAM. When make failed the first time, realized that swap was a measly 300Mb. First steps first, went on to increase memory to 2GB (that's all I can spare) and increased swap to 2Gs.


Compilation next round started and that failed too - ran out of disk space - and this was Sunday night. Things kind of stayed there and finally this evening, resized the disk in virtualbox to 50Gigs. Again started the compilation and this time ran into linker errors when building webcore. One more round of troubleshooting involved deleting the previously built static library and then running make again. Surprisingly, this time make completed successfully - to the point where I wasn't sure if it had succeeded or just failed silently on something else.


The next step was to run the emulator to see if it really would boot up. Over at source.android.com, they oversimplify it when they say that you just run emulator from the android root folder. That didn't work for me - and this time it was because I hadn't sourced the envSetup.sh file... this thread http://groups.google.com/group/android-platform/browse_thread/thread/91ff18e034acf951 helped in tracking that one down.


So finally, after all that trouble, I have my very own ICS build running!!!!


For now, its onward ahoy to setting up Eclipse and starting with a fix I've been mulling about for sometime now..


Signing off from cloud nine
R

Monday, January 16, 2012

Ubuntu, Console VIM - weird characters in insert mode

Now that I feel quite comfy with VIM, over the weekend I needed to edit a config file in my Ubuntu 10.10 Virtualbox machine quickly. Instead of GVim, I just opened the file in console VIM. As I hit i to get into insert mode, a bunch of weird character boxes were inserted. That was not good at all :( - just when you think you're comfortable with something if it does something totally weird. In any case, I was in too much of a hurry to bother and went about editing my file with gVim. Also, backspace was wonky (same weird characters) - so I felt better. For some reason that I fail to understand, why must Linux make proper backspace and delete handling such a pain! In any case, it's something that I've dealt with enough times to know that there'll be something on Google.


Later on, tried to see what all the fuss was about. Googling around, I found :help :fixdel and that seemed simple enough. Alas, when I tried it out, it didn't fix the issue at all. Also, I seemed to be getting weird characters just pressing i to get into insert mode - and the VIM wiki page didn't have anything about that. Neither did Google turn up anything that seemed related.


So today early morning, on a whim, read up a little on VIm terminal handling. I have the following in my .vimrc
[sourcecode language="text"]
set t_Co=256
[/sourcecode]
Maybe it was the color escape code that was coming in - so checked out :echoe &term which returned xterm under gnome-console and builtin_gui under gvim. So I've put the following bit in my .vimrc and it seems to have fixed things nicely:
[sourcecode language="text"]
if &term == "xterm"
set term=xterm-256color
endif
[/sourcecode]

Wednesday, January 11, 2012

Android Annoyances

So yesterday and today while driving back from work, I've had to join conference calls. The conference call provider we use at work has 10 digit passcode numbers. Usually, I have a few bridge numbers with the DTMF codes saved in my contacts so I can just click on the contact to get dialled to the access number and have the participant passcode typed in for me. However, yesterday and today's calls were on a different bridge and I had to try to remember a 10 digit number after dialling the access code - and all that while driving. Needless to say, it took a few attempts and I'm sure at that time my attention wasn't where it should have been - ie on the road and on the traffic. Besides being thoroughly unsafe on Bangalore roads, its just frustrating(thankfully - better sense prevailed today and I pulled over, dialled into the bridge and then started driving again).


So the issue really is that the native parser that parses out email and calendar invites doesn't understand access codes and passcodes. It shouldn't be too hard to do - but then I started digging a bit deeper this evening. Granted that the parser isn't smart enough, at the very minimum if it handles tel: links properly, then its just a matter of educating folks who set up meetings to set them up so that you can click to call with something like <a href="tel:23423432233,,9230233#"> - in fact, in Outlook if you type TEL: and then the number, it will automatically be parsed as a tel: hyperlink. Turns out that its a massive fail - if I click the link, Android will show me the dialler but without the DTMF codes (basically, only the number upto the first comma). TOTAL FAIL.


So, Isn't this something that should have been brain dead simple to do? I mean - this is 2012 after all - and I'm not asking much. All I'm asking is that the tel: url parsing/handling be done in such a way that we can use our phones properly!!! Turns out that there's an open ticket 4575 since Nov 09. And its marked as an enhancement - I find that laughable since its a bug and definitely something that can be done quite easily (esp since a contact that has DTMF codes is dialled properly). However, for the 2 years that the ticket has languished, there have been 73 comments and not a single response from big GOOG :(


At the moment, doesnt look like this is going to be fixed - so I started browsing thru the Android source tree to see if I can find where the implementation for tel: urls - however, given the size of the android source, that's like trying to find a needle in a haystack. Guess I'll have better luck with seeing if CyanogenMod folks can fix this in CM9.


So about that, the other thing that has confounded me is why in the world can't Android bundle a decent T9 dialer/smart dialer out of the box. I know there are tons of apps on the market that do that - but seriously, is smart dialing something so out of the world that I need an app for it? As expected, there's a ticket but no action.


I think its safe to assume that Google isn't interested in fixing these issues as there's no 'benefit' in doing so - though for the life of me, I can't imagine either of them being particularly hard. In any case, I'm eagerly awaiting a CM9 build for the Nexus One (right now, am running an ICS build from XDA).

Tuesday, January 10, 2012

Facebook publicize is driving me nuts!

I'm thoroughly frustrated with Wordpress.com's facebook publicize feature. In theory, its supposed to post to your facebook wall whenever you publish a new post and that way publicize your post among your friend circle.....if it ever works. I've done all the resets, disconnects and reconnects and it just doesn't. Now, this could very well be a facebook problem rather than a wordpress.com problem - so while my rant might be misdirected, its a rant anyway against the thoroughly frustrating experience. Its like a bucket of cold water on my enthusiasm to be more active on my blog.


You see, with having posted rarely to this blog, I get a measly 70/80 page views per day (yeah - there's no need for the snide looks); So one part of actively persisting on the blog has been to see if I can get to 100+ page views per day. Modest goals, I admit - and getting the linky to a new post on the FB wall is a big part of it. If only it worked as it says on the tin :( :(


Anyway, this post is a test in itself - I've just jumped through the said hoops , mumbled the magic incantations and in other words, followed every bit of direction available to make this work right. And if this post shows up on my FB wall, well and good. If not, then I'm done with trying to get this to work.

Monday, January 09, 2012

A syntax highlighter extension for Deck.js

So for the past few hours, have been playing with Deck.js . I like the idea of a web based presentation format rather than a blob like powerpoint. At the same time, I'm a bit circumspect too - given the state of the tools. At least for my use, there's really no burning need that powerpoint can't solve (though I get the shivers everytime I have to do a presentation). All the web based/HTML5 seem raw at the moment on some much needed features (slide notes, slide prints, scaling issues etc).

Anyway, after a few minutes on Google and StackOverflow, decided to give Deck.js a spin. Deck.js is really nice and you should take a tour if you haven't done so. So finally, after giving the online presentation and the introduction a try, downloaded the latest to give it a more thorough spin. As usual, one of the first things was embedding code snippets and I thought it would be nice to integrate Alex Gorbatchev's SyntaxHighlighter into this. Turned out really simple to do (I'm sure there are other syntax highlighter extensions to deck.js out there) - but since I got something working pretty easily, here it is:

Create a file called deck.syntaxhighlighter.js with code below:

[sourcecode language="javascript"]
(function ($) {
$("head").append(
'<link href="http://alexgorbatchev.com/pub/sh/current/styles/shCore.css" rel="stylesheet" type="text/css" />'
).append(
'<link href="http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css" rel="stylesheet" type="text/css" />'
);
function setupSyntaxHighlighterAutoloads() {
console.log("calling SyntaxHighlighter");
SyntaxHighlighter.autoloader(
'applescript http://alexgorbatchev.com/pub/sh/current/scripts/shBrushAppleScript.js',
'actionscript3 as3 http://alexgorbatchev.com/pub/sh/current/scripts/shBrushAS3.js',
'bash shell http://alexgorbatchev.com/pub/sh/current/scripts/shBrushBash.js',
'coldfusion cf http://alexgorbatchev.com/pub/sh/current/scripts/shBrushColdFusion.js',
'cpp c http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCpp.js',
'c# c-sharp csharp http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCSharp.js',
'css http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js',
'delphi pascal http://alexgorbatchev.com/pub/sh/current/scripts/shBrushDelphi.js',
'diff patch pas http://alexgorbatchev.com/pub/sh/current/scripts/shBrushDiff.js',
'erl erlang http://alexgorbatchev.com/pub/sh/current/scripts/shBrushErlang.js',
'groovy http://alexgorbatchev.com/pub/sh/current/scripts/shBrushGroovy.js',
'java http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js',
'jfx javafx http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJavaFX.js',
'js jscript javascript http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js',
'perl pl http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPerl.js',
'php http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPhp.js',
'text plain http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPlain.js',
'py python http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPython.js',
'ruby rails ror rb http://alexgorbatchev.com/pub/sh/current/scripts/shBrushRuby.js',
'sass scss http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSass.js',
'scala http://alexgorbatchev.com/pub/sh/current/scripts/shBrushScala.js',
'sql http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js',
'vb vbnet http://alexgorbatchev.com/pub/sh/current/scripts/shBrushVb.js',
'xml xhtml xslt html http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js'
);
SyntaxHighlighter.all();
}
$.getScript("http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js",
function () {
$.getScript("http://alexgorbatchev.com/pub/sh/current/scripts/shAutoloader.js",setupSyntaxHighlighterAutoloads);
});
})(jQuery);
[/sourcecode]

Throw that in your deck.js/extensions folder. IN the slide deck you want to use this extension, include a script line before the end of the body tag:

[sourcecode language="html"]
<script src="../extensions/deck.syntaxhighlighter.js"></script>
</body>
</html>
[/sourcecode]

And you're done. Now to include any code snippets in your deck, just use either of the methods specified in the SyntaxHighlighter page (snippet for the script tag below)

[sourcecode language="html"]
<script type="syntaxhighlighter" class="brush: js">
$(document).ready(function () {
//this is the function body
});
</script>
[/sourcecode]

That's all there is to it. Code above can do with some improvements (conditionally load local copies if the remote loading fails etc) - but this is just a quickie script - so feel free to modify this to your heart's content.

Friday, January 06, 2012

Vim - unmap Esc!!

So I had the bright idea (by no means original, though, as I later figured out) that it'd be great to avoid the Esc key on Vim as its so far away from the home row. The alternative to pressing Esc is Ctrl-[ which, even though I've mapped CapsLock to control, I still find hard. So then, after some more googling around I've settled down on mapping jk to Esc. Its been a few hours with this setup and while its been an absolute pain till now, I think its a great way to avoid the Esc key jump. I can already feel my finger muscle memory relearning and my hand jumps instinctively for the Esc key much less now.

Here's my setup in case you want to try this out. Bung the following into your .vimrc or _vimrc as the case may be:

inoremap  :echoe "use jk"
inoremap jk 
The first mapping makes VIM echo a reminder. Its not friendly since it introduces a pause. However, the idea is to make the Esc so painful that you will shy away from hitting it.

Upgraded to XBMC 11.0 Eden beta

So I upgraded the good ole' media center machine at home to XBMC 11.0 Beta
. XBMC has been one of those software finds that has been just marvellous - to the point where I can't imagine the telly at home without XBMC. I've pretty much stopped watching regular tv/cable and almost exclusively on XBMC.
Also, its been a great way to keep the aging laptop (circa 2006 - core2Duo 1.6 Ghz, 2 Gb RAM and a piddling ATI Radeon X1600) in active duty.
Here's a hat-tip to all the XBMC guys and gals. And if you're not running a media center at home, you should give it a spin - XBMC makes your idiot box smart!