Posts

Web Crawling using Apache Nutch + MySQL + Solr

If you have come here, then you probably know what Nutch is and you are looking for a test to integrate it with MySQL and Solr or Elasticsearch. So, lets get started. I am not going to guide you with the steps, but give you this awesome link which helped me run a test crawl in couple of hours. Technically, it should have taken not more than half hour, but I had to spend more time trying to figure out the issues mentioned below on my Mac - El Capitan. Firstly follow the steps mentioned in this link.  https://anil.io/post/92/apache-nutch-2-2-mysql-and-solr-5-2-1-tutorial In the process of trying to make things work, you may come across the following issues. I have provided solution for each below 1) Don't ignore this step [STEP 2 in the link above] export JAVA_HOME = "$(/usr/libexec/java_home -v 1.8)" export NUTCH_JAVA_HOME = "$(/usr/libexec/java_home -v 1.8)" 2) Issue when creating the database nutch in MySQL. [STEP 3. 2 in the li...

Search strings from a list using Radix Tree

A logic to build a Radix tree (not completely though..) to search a string from a list of strings. Ideally the radix tree should be built something like this , but the logic below constructs a node for every character in the string. using System ; using System.Collections.Generic ; using System.Linq ; using System.Text ; using System.Threading.Tasks ; namespace RadixTree { class Program { public class Node { public char _Character; public List<Node> _Children = new List<Node>(); } private static List<Node> traversedNodes = new List<Node>(); private static bool stopTraversing = false ; private static string wordString = "" ; private static string mainString = "" ; private static string [] searchStrings = new string [] { "Chicago" , ...

Ionic app for Windows 8.1, Windows 10 and Windows Phone

If you like me have bumped into crazy issues like the ones mentioned below when attempting to build an Ionic app for Windows 8.1/ 10 and Windows Phone, then the following tips will definitely help you. Adding the windows platform ionic platform add windows Note: ionic platform add wp8 is deprecated, but you can test this on windows 8.0 at your own risk. Inside the platform/windows folder you will see a solution named CordovaApp. Open this and you will see three projects CordovaApp.Phone CordovaApp.Windows CordovaApp.Windows10 You can either choose to open the main solution containing all the three projects i.e CordovaApp or open each individually for a particular platform.  Note: I have used Visual Studio Community Edition 2015 and tested on both Windows 8.1 and Windows 10. Now the interesting bit. When you build the project, you will see any or all of the below mentioned issues 1) A broken reference to Win JS "Could not find SDK Win JS 2.x.......

iOS Linking errors - missing required architecture i386

If you have ever faced issues similar to the one below ld: warning: ignoring file ../lib/iPhone/xxxxx.a, missing required architecture i386 in file ../lib/iPhone/xxx.a (3 slices) Undefined symbols for architecture i386:   "_OBJC_CLASS_$xxxxxx", referenced from:       objc-class-ref in ViewController.o   "_OBJC_CLASS_$xxxxxx", referenced from: then most probably your project is set to test in a simulator. Change this to device, Command + B and magic!  Remember, never ignore the warnings and always read it completely. In this case, Xcode ignored linking the xxx.a file in the iPhone directory due to compatibility issues. I spent couple of hours on this one. Arrrrghhhh!

When Rackspace is down

Image
Neat!!!

SSH on Mac keeps asking for the private key password

If you have come here because of a dialog that keeps showing up each time you attempt to ssh on mac with or without a passphrase, maybe this will help you. Issue: I generated a public / private key without a passphrase using the putty key gen on windows. Copied id_rsa.pub and id_rsa.ppk to ~/.ssh directory on my Mac Ran the below command ssh -i id_rsa.ppk xxx@xx.xx.xx.xx I kept getting the dialog asking for the password. After three attempts, it would terminate with a permission denied error. Failed attempts: Attempt 1: Renamed id_rsa.ppk to id_rsa Ran the below commands chmod 600 id_rsa ssh -i id_rsa xxx@xx.xx.xx.xx Attempt 2: Renamed id_rsa.ppk to id_rsa Ran the below commands chmod 600 id_rsa sudo ssh -i id_rsa xxx@xx.xx.xx.xx and more... Successful attempts: Download puttygen.exe Import (Conversions -> Import Key) the private key id_rsa.ppk Click Conversions -> Export OpenSSH Key Save as id_rsa.pem Copy id_rsa.pem to ~/.ssh. You sho...

NSArray, NSNumber, NSValue... What is 'NS'? What is 'IB'?

In Objective-C, NS stands for NeXTSTEP , the platform for which these classes of the Foundation Framework were originally designed. While it helps, but I like it when it is Number instead of NSNumber , and Array instead of NSArray .  Similarly, IB in IBOutlet and IBAction stands for Interface Builder which is the tool used for designing the user interface of your apps. The interface builder file has the extension .xib (originally .nib) NeXTStep was an object oriented operating system based on UNIX. Remember the story of Steve Jobs getting sacked from Apple, and then founding NeXT and then folks in Apple begging him to come back? Just makes you wonder how amazing Steve was. Something developed in the 1980s to 1990s becomes the building block for most of the apps built on iOS and OSX today. Simply brilliant!

Sentinel Value

In computer  programming , a  sentinel  value (also referred to as a flag value, trip value, rogue value, signal value, or dummy data) is a special value in the context of an algorithm which uses its presence as a condition of termination, typically in a loop or recursive algorithm. More info on the same here  https://en.wikipedia.org/wiki/Sentinel_value In Objective-C it looks something like this where 'nil' is the sentinel. NSArray *arrayElements = [ NSArray arrayWithObjects : @"One" , @"Two" , @"Three" , @"Four" , nil ];

JackOfAllThreads - First attempt

Image
My first attempt at JackOfAllThreads I know this blog is not for this.. but hey! a little marketing for my campaign does not hurt. You like it? You can buy it by clicking on the link below. http://jackofallthreads.co/Look-at-me

CISC vs RISC

Image
One of the best explanations on these two architectures.

Visual studio code

It would be nice to have visual studio on OSX too.. so here it is. https://code.visualstudio.com/  

Objective C on windows. OMG!!

So much to compile and run Objective C on windows?? http://www.gnustep.org/windows/installer.html But if you still want to go ahead then.. http://sweettutos.com/2012/08/11/objective-c-on-windows-yes-you-can/

MonoDevelop plugin

After a lot of researching I finally managed to write a plugin for MonoDevelop the right way.  You will find the source in the link below. The plugin does the following functions 1) Checkout from perforce using command 2) Fix line endings - Extra space added in a file due to line ending issues between windows and unix. Hope you like it. https://drive.google.com/file/d/0B_8vwjDBEtcqMjU5Wmg1X2FsSHc/view?usp=sharing

Why are iPhones so expensive?

Check out this link. It is beautifully detailed and makes a lot of sense. http://www.techarp.com/showarticle.aspx?artno=831

Null Object Pattern

Want to avoid the crazy if conditions in your application and ensure that it does not crash and yet provide a good logging mechanism? Use the Null Object Pattern. You will end up writing in more classes but it will help you make a good stable app. Imagine you are trying to find something in a hierarchy; lets say a game object. Lets say the method used to find this gameobject is FindGameObject("Avatar") which returns either null or a valid game object. You cannot guarantee that this method will always return a valid game object. So you end up adding a condition like this GameObject obj = FindGameObject("Avatar"); if(obj != null) Printf("Do something"); Imagine if the hierarchy is long and you end up nesting the conditions like this GameObject objRoot = FindGameObject("Avatar"); if(objRoot != null) GameObject objParent =objRoot.FindGameObject("AvatarMain"); if(objParent != null) GameObject objChild = objParent.FindGameObjec...