Friday, June 21, 2013

JavaScript convert signed integer to unsigned integer or Int32 to UInt32

Try this in your browser:

    document.write((1 << 31));

What do you get? Is it -2147483648?

So, why is it negative? The reason for this is that JavaScript Bitwise Operators convert your number into 32 bit signed integer. 

The trick and absolutely the simplest and fastest to flip between int32 and uint32 is to use zero-fill right shift like this:

    document.write((1 << 31) >>> 0);

Voila! This time you'll get 2147483648? Simple? Keep in mind that doing >>>0 again will flip uint32 back to int32.

Friday, May 3, 2013

FileSystem inspector in Chrome Dev Tools

I love Chrome, but some features are hidden so deep that if you find them once, you are not sure you'll remember where there were.

So, you are playing with HTML5 FileSystem API and you need to see if Chrome created/saved/deleted your files or folders. There are few tricks that suppose to make your life simpler, but ... they didn't work for me because I my application is not a regular web page but Packaged App. That's why I was so happy to see that Chrome Developer Tools now include FileSystem inspector.

Here is how to enable FileSystem inspector:
- Go to chrome://flags/ and enable "Enable Developer Tools experiments"
- Restart Chrome
- Open Developer Tools and click on Resources tab.
- Click Setting (gearwheel icon at the bottom right corner), then "Experiments", and then "FileSystem inspection":


- You may need to restart Chrome again. After that you should see "FileSystem" option on "Resources" tab:


Cheers!

Thursday, April 18, 2013

Peeper Flash plugin in Chromium on Linux (Ubuntu)

Let's say you installed Chromium into your $HOME folder and discovered that there is no Flash plugin.
The solution is simple.
Step 1: Get Google Flash Plugin for Linux. See reference to other post at the end.
Step 2: Run chromium with command line switch "--ppapi-flash-path"
Example:

$HOME/chrome-linux/chrome --ppapi-flash-path='$HOME/chrome-linux/libflashplayer.so'

I borrowed that idea from this post, so all credits should go there. You can find more details there as well.

-= Oleg =-

Thursday, April 4, 2013

Mini PC - MK809 - USB Driver not recognised by ADB

It took me a while to figure out how install USB driver for MK 809, but I did it. And I did it several times using different methods because I couldn't make adb to recognise it. Finally, I came across the post that suggested to add driver vendor ID  to the "C:\Users\<your username>\.android\adb_usb.ini" file. I did it and it WORKED!!! Here is it looks:


# ANDROID 3RD PARTY USB VENDOR ID LIST -- DO NOT EDIT.
# USE 'android update adb' TO GENERATE.
# 1 USB VENDOR ID PER LINE.

0x2207 MiniPC driver

I'm so happy I can now debug my application on Mini PC from Eclipse. The only sad part is that my application requires WIFI and what I discovered is that when you check "USB / Connect to PC" in Android settings, then WIFI gets disabled. This seems like a limitation of this tiny device :(

-= Oleg =-

Tuesday, April 2, 2013

How to fix "Android Fix: Eclipse is loading framework information and the layout library from the SDK folder. main.xml will refresh automatically once the process is finished."

I started seeing this error after I installed additional SDK versions. I tried the following:
  • Create a new workspace as suggested in this form post. This didn't make any difference.
  • Looked if I had any older versions of SDK jar files as outlines in this blog post. It appeared that I didn't have any older jar files installed.
  • On a layout designer page, change the Android version used for rendering the layout (see top right corner of the designer window). That didn't help either.
  • Reinstall SDK as suggested here. That actually worked, except that I had to do it slightly differently.
To recap, reinstalling SDK solved the problem for me. BTW, I'm on Android SDK version 4.2.2 and I'm using Eclipse IDE. Here is how to reinstall SDK in Eclipse:
  • open Android SDK Manager. There is an icon in toolbar if you have Java perspective open.
  • Close Eclipse (not sure is this is needed, but that's what I did)
  • Check "SDK Platform" from the latest installed SDK (Android 4.2.2 in my case). 
  • Click "Delete packages". Wait for it to finish,
  • Check "SDK Platform" and all other items that were uninstalled in the previous step.
  • Click Install packages.
  • Start Eclipse.
Good luck!
Oleg.