Category: Technology


For those facing issues with enabling pasting of items from Mac (Mavericks to be specific here) to an NTFS drive…just follow the steps mentioned at OSXFUSE Wiki about enabling NTFS-3G and hence write access on the drive. It works just perfectly.

Advertisements

Scenario

My latest adventure took me towards developing a location tracking application using PhoneGap. The goal was to continuously monitor the location of the user (obviously the user had to permit the app for doing so – Privacy alert!) and share the info with the peers. This required interacting with the iOS Location Services to get the current location coordinates of the user and then sending them over to the backend server via an ajax call, etc. While this sounds easy, I had to go thru various obstacles to reach the right solution. I am going to divide the solution in a series of blog posts to throw light on all situations faced and the good/bad solution choices then finally how the goal was achieved.

What is PhoneGap?

In case you didn’t know, PhoneGap is a framework that allows cross-platform web application development for mobiles using HTML5, JS, CSS3 and without requiring the developer to have experience with the native language of the targeted platform.

Basic Approach

Ever since PhoneGap v3+, it has become much easier to access a device’s native functionalities. PhoneGap is based on Apache’s Cordova project which is a set of APIs (adhering to W3C HTML5 specs) that enables accessing the native device features directly from javascript accomplished via “Plugins”. A plugin is a piece of native and javascript code bundled together, the native code exposes an interface i.e. methods that access the device features and the javascript code is used for enabling invocation of the exposed interface thru user-defined JS code. Depending on the platform the native language varies e.g. Objective C for iOS and Java for android, etc. In this blog, we’ll consider the strictest platform to code for iOS 7. 🙂

Getting Started

To get started, install Node.JS followed by PhoneGap module (which internally installs Cordova) as show hereI had PhoneGap 3.3.0, Xcode5 and command line tools installed on my machine while writing this blog post. Now, if you follow the documentation provided by PhoneGap like a good student you would execute the following commands:

Install PhoneGap

sudo npm install -g phonegap

Create a PhoneGap app

phonegap create MyAppFolder "com.myorg.loctracker" "My Location Tracker"

Add iOS as platform

cd MyAppFolder
phonegap build ios

Add Geolocation plugin

phonegap plugin add org.apache.cordova.geolocation
cd www
vi config.xml

Add the following lines in the file at the bottom (but as a child of widget tag) and save the file:

<feature name="Geolocation">
   <param name="ios-package" value="CDVLocation" />
   <param name="onload" value="true" />
</feature>

Thats it for the configuration part. Now lets just run the app for the first time by:

phonegap run ios

This would automatically launch the iOS simulator with the basic PhoneGap app running on it, that looks like this:

PhoneGap Basic Installation

PhoneGap Basic Installation

The code you see comes from www/index.html page hosted on a native UIWebView control. The cool thing here is you actually have a web app running on your iOS as a native app without actually requiring the code to be hosted on an external server.

Now you have the basic app running. I encourage you to explore the code added in the “plugins” folder to understand the code structure, to given an overview, the native code will be present inside the “plugins/org.apache.cordova.geolocation/src/ios” directory and javascript is at “plugins/org…/www” directory. The Xcode project is located at “platforms/ios/” directory, you’ll need this later.

Congratulations, you now officially know how to create PhoneGap app for iOS. Feel free to explore the API documentation. In the next post, I’ll cover the following:

  • Life cycle of a phonegap app
  • Getting geolocation coordinates on-demand
  • Monitoring location change in realtime

Stay tuned!

I recently was working on making a webpage compatible with the portable devices specifically iPhone & iPad. And when I say compatible, there are only 2 things to keep in mind:

  1. The graphical elements should maintain the layout or gracefully adjusted to remove the horizontal scroll.
  2. The functionalities are preserved – this would include all the dynamic aspects like server side calls, animations, etc.

For the first requirement, we have a really great solution – “Twitter Bootstrap”. Just add it to any page and making it responsive becomes super easy. Of course, it does require the programmer to still have a sense of a front-end designer i.e. just putting the framework in place is not going help, it requires some effort still. I am going to refrain from going into details about the styling aspect in this post and talk about the issues I dealt in terms of functionality.

The second requirement is tricky and get really annoying at times. Some components required replacing, tweaking while somethings were not supported at all. Below, I’m going to mention all the challenges I faced:

  • Custom scrolling solution like jquery.slimScroll had some rendering/processing issues, though iScroll is a good replacement.
  • If you are using text controls than the virtual keyboard can create mayhem for your user experience, the primary reason is when the keyboard opens, the page automatically scrolls up but the original position fails to restore when the keyboard is closed.
  • Sounds & Videos – while on the desktop you can play these as and when required i.e. on page load, based on an event, the iOS web engine only allows the playing of these files as consequence of a user action ONLY. This can totally ruin your UX if you have a auto-playing media files.
  • If the user puts the browser in the background or is working with multiple tabs, then in pre-iOS 7 devices, the pages state will be lost i.e. when the user goes back to the page it’ll open up like you hit refresh. While the query string params in the URL are retained, the post params are lost. In iOS7, I guess there’s a better handling of this particular case where the page is kept in memory but maybe its only for a limited time.

One good thing is jQuery works nicely and the socket.io also is not blocked although Apple only wants to use APNS for their push notifications but then again when the browser is in the background, the page is dead and no processing is done.

How do we handle these cases where we dont want to create a Native App due to lack of time, resources, experience, etc? Well one solution can be PhoneGap, it allows you convert your existing web app into a iOS installable application. Please see that it doesnt cover all the cases mentioned above directly, you would still have to write some native code as an hybrid solution but it reduces a lot of pain. Also, you’ll have to go thru Apple Developer Program and App publishing guidelines to ensure the app is available at the AppStore. It sounds like more of a mess but its a one time investment, for a solution that works!

 

The new Apple Mac Pro

So, it was brought into my attention from a colleague of mine that Apple is building a server-like hardware which I was complete oblivious about. But apparently they have been doing it for pretty long time now. The product I am talking about is the upcoming Apple Mac Pro. This beautiful thing is best described in this caption:

Apple Mac Pro

 

Now, I am not really a big apple fan as my friends know it but when it comes to innovative technology…there’s no barrier for brands in my mind. Considering what I saw on the website…I have only two things to say:

1. This piece of hardware is a kind of a masterpiece. I mean can you imagine having one machine which is brilliantly designed with latest state of the art techonologies in a amazing innovative yet simple design? I am so excited here that I am already contemplating what I can do with this amazing hardware? Use it as a single shared computing hardware among a complete development team that includes designers, developers and testers, etc and it not only hosts the development sandbox but also the staging and product enviroments thanks to virtualization and what not at the same time?

2. Apple is always know to have that UX oomph factor in their UIs…but the website design for this particular page is totally out of the box! I kind of spent 2 hours just admiring it! What would be the best way to design a page like that? Any ideas?

I am definitely adding this amazing machine in my wishlist and if apple prices it nicely, I might actually end up buying it! Or maybe not because to buy a machine like that and not respect it by heavily using it would be an insult to the bright minds who created it! Kudos guys.

 

One of my most recent adventures have been around exploring Ruby on Rails. And the first step towards learning any language is ‘Environment Setup’…and trust me it isn’t as easy as it sounds. There are multiple options available depending on the settings you are looking for and not all of them worked for me. I tried setting the environment for the target project on Windows but failed since some of the gems were localized to Linux based environment i.e. would work only for Mac or Ubuntu, etc. So, I installed Ubuntu 12.04 LTS on my machine and started installing rails and guess what roadblocks – some dependencies not met or in conflicted state, make errors, etc….totally bizarre things and ended up in re-installing the OS again (may be due to my limited knowledge of the free platforms). And this how I felt after this!

frustration-baby

Anyway, gathering my composure after a while, I investigated more on the different frameworks etc. I mean this couldn’t be rocket science, right? So, I came across 2 environments – rbenv and rvm. While rbenv didn’t really provide a fruitful result for me, rvm on other hand was much better. And I finally opened the Pandora box.eureka

So, then I thought like a boss and realized how many innocent noobs like me 😉 would have gone thru the same situation and how many more would do the same. So, to save the effort I chalked down a script that would work with minimal customization. The script does the following:

  1. Prepares the OS with the required packages e.g. LAMP, etc.
  2. Installs Ruby using RVM. This script is currently configured to install Ruby version 2.0.0-p247 but of course you can customize it.
  3. Installs the ruby gems (including the Rails framework).

Please see the script is targeted for Ubuntu Linux and is tested on version 12.04 LTS x64. During the span of the script execution your machine should be connected to internet at all times.

To use the script, follow the steps below precisely:

  1. Open the script in an editor and modify rvm lines of code to install your preferred version of ruby. I assume you would know the version of Ruby you would want to install. Please note, you have to modify all the 3 lines of rvm in the script to use the same ruby version. Currently the lines look like this:
    rvm install 2.0.0-p247
    rvm use 2.0.0-p247 --default
    
    
  2. Save your changes and open terminal.
  3. Go to the location where the script file is saved e.g. cd /home/akshaya/
  4. Give executable permissions to the file: chmod uog+rwx RoREnvSetup.sh (name of the script you create)
  5. Execute the script by: sudo ./RoREnvSetup.sh (NO MATTER WHAT DON’T RUN THE SCRIPT AS ROOT USER i.e. DON’T DO “sudo –i” before, unless you are the root user and plan to do all your work as the root user!)
  6. During the installation, it’ll ask prompt you after password you want to set for MySQL DB, etc., please provide it.
  7. Thats it! You have Ruby and Rails installed on your machine.

The RoREvnSetup.sh script is shown below:


sudo apt-get update -y
sudo apt-get upgrade -y
sudo apt-get dist-upgrade -y

echo "gem: --no-rdoc --no-ri" > ~/.gemrc
echo "export RAILS_ENV=development" >> ~/.bashrc

sudo apt-get install curl -y
\curl -L https://get.rvm.io | bash -s stable
source /etc/profile.d/rvm.sh
echo "export rvm_trust_rvmrcs_flag=0" >> /etc/rvmrc
rvm requirements

sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev libc6-dev ncurses-dev automake libtool bison subversion ncurses-term mercurial exuberant-ctags libnotify-bin curl autoconf make ssh openjdk-6-jdk git-doc imagemagick libpq-dev pgadmin3 vim vim-rails vim-gnome lamp-server^ mysql-client libmysqlclient-dev libgdbm-dev libncurses5-dev libffi-dev nodejs -y

rvm install 2.0.0-p247
rvm use 2.0.0-p247 --default
gem update --system
rvm gemset use global
gem update
gem install rails

The future of phones

Xaml Spy usage problem

XAML Spy (previously known as Silverlight Spy) is quite famous with Silverlight development groups to investigate into existing XAML based applications. It provides quite an insight to the developer if not the exact solution for a given scenario. I have used the older version ‘Silverlight Spy’ multiple times in the past to get the details of how the Pivot Viewer control works, etc. But with XAML Spy released, I felt a need to have a hands on experience to see the changes. So, I downloaded the tool, added my application (built in Silverlight 5) but the XAML Spy didn’t detect the application…I tried checking the app for errors but nothing, the app was running perfectly in Visual Studio. So, I thought about using the older version of Silverlight Spy and to my amazement, the app was detected and I was able to explore the XAML as well! Now, whats going wrong?

I was about to send a mail to the support but I thought to doing what us developers are not used to or just don’t want to do…Read the Tutorials :), I stumbled around the page Manually connect a Silverlight app (having no idea what it means), but followed it and Eureka…XAML Spy now detected my application.

Although its working, my question to the First Floor Software team is why such a requirement? Why does the customer require to modify their codes? What to do when the app is not really yours and you cant modify it?

Links

For the record, the following links were what helped point me in the right direction, however as you will find, not everything in here is correct.  I do believe they are good for reference, and to get a good idea of the inner-workings of AD RMS, SharePoint 2010 and IRM:

After doing a LOT of research on this issue I came to a conclusion; Microsoft SharePoint 2010 (all versions) support IRM out of the box, however, the free version (and I cannot speak to the paid versions) DOES NOT contain the Office Document Protectors by default, nor does SharePoint look anywhere near where Microsoft tells you that it looks when registering your custom IRM protector!  I believe that part of the misunderstanding as of this writing is that Microsoft simply copied over a bulk of the documentation used for IRM in SharePoint 2010 from an earlier version (SharePoint 2007).  Come to find out, this was the root cause of the problem I was having, but we will get back to that.

The Setup (basics)

After configuring Active Directory Rights Management Services, the next step is to download and install SharePoint Foundation 2010.  This is a pretty simple process, only really involving the prerequisites and hitting “next” a lot picking the defaults (in our example).  Once SharePoint is installed, you will need to enable Information Rights Management (IRM) at the SharePoint Management Console level, and then you will actually control what document or list libraries have IRM applied and the extent of the permissions on EACH library.  However in order for those options to work, SharePoint must be set to use your current AD RMS server, but I’ll leave the details to all of the documentation that is out there.  It is pretty simple and errors generally point to a misconfiguration of AD RMS, DNS, or incorrect registration (or no registration) of the SCP for RMS.

Once IRM is setup at the server (or server farm level), then just create your SharePoint site(s).  Once created, all the documentation out there for SharePoint 2010 implies that setting the document library settings to use rights management should “just work”.  However I found out very quickly that by checking the box in the library settings that would not allow me upload documents that could not be rights managed, that nothing would upload.  Nothing.  Uncheck that box, uploads work, but no rights are applied!  From here it was back to ensuring that AD RMS was working properly, that IRM was registered in Active Directory, but still I was getting the same problem, SharePoint was not seeing any documents types that would work with IRM.  I began to research even more and found one blog post on TechNet that mentioned although Microsoft stated SharePoint 2010 (including Foundation) would work with IRM/RMS it wouldn’t work out of the box the same way that the full (paid) versions do.  Unfortunately it did not go into any detail about how to make it work, just that it should work, but didn’t come with the needed components that would allow it to work.

 

The Plot Thickens

Armed with the knowledge that SharePoint Foundation 2010 does not include the needed components that we need in order to actually use the Microsoft Office document protectors (as that is all Microsoft specifies will work with SP 2010), it was simple enough to find several others that utilized the Microsoft Office File Format Protectorsin order to actually build the dll’s from Microsoft-provided source code and then install them into WSS 3.0.  Following the directions in the “Extend WSS 3.0 to Protect…” link above I installed Visual Studio 2010 (full version, but as a trial) to the server as I needed to build it as x64 bit AND ensure that the components were correctly registered on the server.  Unfortunately building the dll’s locally and moving them out to the server does not register the dll’s like we need, and manually registering them did not work, thus the install of VS 2010 on the server and just building the projects register the dll’s.  Now that I had made sure IRM was setup in SP, and now I had the dll’s registered on the server, my hope was that this should work.  Restarting IIS, attempting to upload a document was still telling me that it was not IRM-compatible. ARGH!

Back to research.  Things still were not working as I had anticipated, Microsoft Office document types (new and old) would not upload to SharePoint when I forced IRM protection to only allow documents that could be protected to be uploaded.  I had followed the other posts from Microsoft’s site, on How to: Register an IRM Protector and that even references SharePoint 2010, and goes into detail about the location of the registry keys at: HKLM\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\ and HKLM\SOFTWARE\Microsoft\Shared Tools\Web Server  Extensions\12.0\.  everything was in its place, nothing was working.  So on to more documentation!  I parsed through (probably for the third time at this point) the MS documentation on Information Rights Management in SharePoint Foundation and decided that I wanted to go through their sample as I MUST be missing something in the code, or just not understanding something correctly when I hit another roadblock.  The Sample: Creating Custom IRM Protectors shows a fair bit of code (not all of it), and mentions that the “SampleDocProtector” code sample can be found  in the ECM Starter Kit in the SharePoint 2010 SDK.  Unfortunately after downloading the SDK and looking in the ECM Started Kit, it was not in there…What the what!?  Ok, so I re-routed my search and was able to find that there was also an ECM Starter Kit in theSharePoint 2007 SDK.  This might have been a good indicator that in fact Microsoft was a bit behind in their documentation, however I know this is not the first time I was pointed one place and had to go elsewhere, so I didn’t think much more about it.  My main goal here was to see their sample project and see exactly how it was building/registering itself with SharePoint (as there was also mention that it included a .reg file for registering the protectors and I hoped it would be something different than what the MS documentation was telling me).  No dice.  It was exactly what I expected.

 

More Dead Ends

At this point I had burned a lot of time, reinstalled SharePoint Foundation 2010 several times, and still couldn’t get as much as an error to show up in the event logs, SharePoint logs, IIS, anywhere!!  According to each application, everything was operating normally.  I installed Office 2010 Pro Plus on the server to ensure that the AD RMS client on the server had been activated and everything was accessible (and everything worked great using AD RMS in Office, but IRM in SP was still doing the same thing!).  I brought Nolan into the game at this point since I had been looking at this and reading up on it for days, all pointing back to that fact that it should “just work”.  We decided to try a few things that I had tried previously with some different twists, but no matter how we sliced it, the problem was the same, same error, and no matter how verbose the logs in SharePoint, we really weren’t able to discern what the problem actually was.  Enter the nightmare of the impatient, Process Monitor.

 

One of These Things Is Not Like the Other

Our first run of procmon was really to find out what was happening with SharePoint and where it was having a problem.  Our assumption was that there was a problem with SharePoint or the custom dll’s from Microsoft.  After a few hours of digging, re-digging and searching, we had another thought: what if we are looking for the wrong thing, instead of looking for what was wrong, we needed to look at what WASN’T happening.  Sure enough within minutes we were able to figure out that Microsoft’s documentation was incorrect and instead of registering the IrmProtectors in the registry under the HKLM\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\12.0\ we needed to register them at: HKLM\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0\.  The problem was that all of the processes and everything that was happening with SharePoint, that it was not looking under the 12.0 sub key and was only looking at 14.0.  Once we made that change, restarted IIS, everything worked!!  To clean things up a bit, I searched the registry for the GUID’s of the Mso and Opc protectors (from the MS code that we built on the server) and changed the registration of the dll’s to point to a C:\Protectors folder where I copied the two dll’s to, and in addition for older MS Documents types to work (.doc, .xls, .ppt), you will also need to create a subfolder from where the dll’s are located named 1033, and place the provided templates (look in the templates folder of the project MsoIrmProtector) in there.  If you do not then you’ll get the same error when attempting to upload those older document types to SharePoint Foundation 2010 if the library requires only IRM-protectable documents.

 

Review

For those of you that got lost in the novel above or just want a quick answer:

  1. Install and configure AD RMS
  2. Install and configure SharePoint Foundation 2010
  3. Configure IRM at the SP server/farm level
  4. Install VS 2010 (of export all the needed registry keys for the registration if you want to take the time) – and build the projects (ensuring they are set to use x64 if needed)
  5. Add in the registry keys under the HKLM\SOFTWARE\Microsoft\Shared Tools\Web Server  Extensions\14.0\
  6. Restart IIS
  7. Test to ensure that at least the newer MS document types are working (.docx, .xlsx, etc.)
  8. If things work, continue, if not, troubleshoot any errors (look in event logs, SharePoint logs, etc.)
  9. Copy the dll’s from the project files to a more desired location (i.e.: C\Protectors)
  10. Copy the templates in the MsoIrmProtectors project to a subfolder of the dll’s location (i.e.: C:\Protectors\1033)
  11. Adjust the following Default keys to match the location in #9 above:
  12. HKEY_CLASSES_ROOT\CLSID\{2E4402B2-F2DA-4BC8-BB2C-41BECF0BDDDB}\InprocServer32
  13. HKEY_CLASSES_ROOT\CLSID\{81273702-956F-4CBD-9B16-43790558EE29}\InprocServer32
  14. Restart IIS
  15. Test to ensure all MS Office documents types supported are working.
  16. If you have a server farm, it would make more sense to actually create a setup project in Visual Studio and use that to create an installer that will make the changes needed for your environment instead of installing VS on each server, etc.

Finally

If you have any additional input, or need more information/assistance please contact Intrinium and we would be glad to help!  All the information needed is contained above in the article or one of the associated links.  I would highly recommend reading through the links and getting a solid understanding of AD RMS and IRM in SharePoint 2010 before even starting on this type of project.  And, as always, do this in a test environment and ensure that you have a full backup of all data before doing ANYTHING to a server.  If you choose to do this in a production environment, proceed with caution and only use AD RMS if you have the proper licenses!

Source: Intrinium Networks / IT Security > Blog – SharePoint Foundation 2010 and Rights Management.

 

Microsoft surely rocks…and here is the reason!

Pivot Viewer v2 (released as a part of SL 5 RC) is one of smartest improvements done by MS to its own products. However, there are still somethings which are not very clearly available. For instance, sorting multivalued facets, custom actions, etc. In this series of blogs, I am going to explain to you how one can do the tasks which were quite easy in the old version of Pivot Viewer but not so straight forward in this version and then later I’ll take you through how you can harness the power of this newer version of the super awesome product. The series will evolve as follows:

Stay tuned!