Posts

Experiential learning

I have always challenged myself to learn. In fact that's an ingredient that keeps my own sanity in place. There are days when there is no learning and just doing. Those are the kind of days I really dislike. For last nine months I have learnt to become a full stack web-developer from having an absolute zero background in software development. In this post, I want to shed some light on the way I learned and how I feel right now. I am especially going to focus on the ways you can learn anything new, maybe this is contextually more related to technology skills, but nonetheless its an interesting insight into how some of us manage to learn new things with 'ease' and some keep going through perennial struggle and mostly just give up. Just Do It Yeah, that's right. The best way to teach yourself something completely new and complicated is to just observe how it translates into reality. When we are talking about technology there is no better way to learn systems and fram...

WIKIPEDIA API and ChatBots

I have been trying to use ontological bases in my chatbot to introduce interactivity which can take the conversation forward. What I have till now : Any user query is parsed by an NLP engine to classify if the intent is any one of the preset intents. Some of these preset intents are greetings, compliments, tasks assigned in the Talentify for Business app amongst a few. If none of the intents are matched then the user query is passed in sequence to various search engines and their web results are scraped to get a metadata response generated by the search engine, which usually is a representation of the internal knowledge graph of the search engine implementation. If none of the search engines can identify that query, then the query is passed to a knowledge engine called wolfram alpha which in most of the cases can give response to even very complex queries like "what is the distance between Chennai and Bangalore in kilometres" If even that fails then a default random...

Getting same MD5 from java and javascript

Java: try { String plaintext = "test123"; MessageDigest m; m = MessageDigest.getInstance("MD5"); m.reset(); m.update(plaintext.getBytes()); byte[] digest = m.digest(); BigInteger bigInt = new BigInteger(1, digest); String hashtext = bigInt.toString(16); // Now we need to zero pad it if you actually want the full 32 chars. while (hashtext.length() < 32) { hashtext = "0" + hashtext; } System.out.println(hashtext); javascript: var MD5 = function(s){function L(k,d){return(k<<d)|(k>>>(32- d))}function K(G,k){var I,d,F,H,x;F=(G&2147483648);H=( k&2147483648);I=(G&1073741824) ;d=(k&1073741824);x=(G& 1073741823)+(k&1073741823);if( I&d){return(x^2147483648^F^H)} if(I|d){if(x&1073741824){ return(x^3221225472^F^H)}else{ return(x^1073741824^F^H)}} else{return(x^F^H)}}function r(d,F,k){return(d&F)|((~d)&k)} function q(d,F,k){return(d&k)|(F&(~k))} function p(d,F,k){return(d^F^k)} function n(d,F,...

Using cookies with HttpURLConnection

Before the advent of REST, we services were stateful. There were cookies sent with every HTTP request to maintain the state of the client using the services. When we use HttpURLConnection (Java) we need to discretely mention the cookies in the header and store it somewhere for maintaining the session. Below is an attempt using a singleton class for maintaining the session details and some sample HTTP methods: First our Singleton to maintain the cookies in memory between successive transactions: package singletonCookieManager; import java.net.CookieManager; /**  * @author absin  *  */ public class EaqerInitializedCookieHelper { private static final CookieManager instance = new CookieManager(); // private constructor to avoid client applications to use constructor private EaqerInitializedCookieHelper() { } public static CookieManager getInstance() { return instance; } } Next, wherever you want to use this class initialize it as such ...

ehCache getting Started

First create a singleton class (CacheHelper) to return an instance of cache: package cache; import org.ehcache.Cache; import org.ehcache.CacheManager; import org.ehcache.config.builders.CacheConfigurationBuilder; import org.ehcache.config.builders.CacheManagerBuilder; import org.ehcache.config.builders.ResourcePoolsBuilder; import com.istarindia.android.pojo.ComplexObject; public class CacheHelper { private CacheManager cacheManager; private Cache<Integer, ComplexObject> squareNumberCache; public CacheHelper() { cacheManager = CacheManagerBuilder.newCacheManagerBuilder().build(); cacheManager.init(); squareNumberCache = cacheManager.createCache("squaredNumber", CacheConfigurationBuilder .newCacheConfigurationBuilder(Integer.class, ComplexObject.class, ResourcePoolsBuilder.heap(10))); } public Cache<Integer, ComplexObject> getSquareNumberCacheFromCacheManager() { return cacheManager.getCache("squaredNumber", Int...

Steinhaus–Johnson–Trotter algorithm

package permutation; import java.util.HashSet; import java.util.Scanner; public class JohnsonTrotter { static HashSet<String> permutations = new HashSet<>(); public static void main(String args []) { // Incorrect(); System. out .println( "Enter the count of integers whose all " + "possible orders will be permuted using Johnson and Trotter" ); Scanner scanner = new Scanner(System. in ); int N = scanner .nextInt(); scanner .close(); int arr [] = new int [ N ]; for ( int i = 1; i <= N ; i ++) { arr [ i - 1] = i ; } boolean [] direction = new boolean [ N ]; // I am using a boolean array of the same size as the number of // integers. A true indicates right, and false indicates left. Don't // judge me for choosing right as true, I am right handed :P. There is // another reason why I chose right as true, by default a new boolean // array in Java...

SOAP REST SERVLET What is the difference?

This is more of a psychological question I think. What is psychological about this? These 3 things together represent something very broad, so broad it may not even share a name. Phew.. differences between boys and girls. Between cat and dog. Pencil and pen. At least those things are close. Asking SOAP vs REST vs SERVLET is like asking 'bat' vs 'bat shit crazy'. So let's take them one by one, then we shall find out the underlying relationship. SOAP: Soap is a construct. The construct demands you to use the Internet in a particular way to achieve your job at hand. It suggests that you send human readable data like XMLs through the Internet using mainly HTTP and SMTP protocols. So if you want to make a blog application. You will send the blog posts as XMLs to your browser which shall be equipped with a JavaScript file to understand and make sense of this fury of information. Coming in on the HTTP and SMTP protocol in extensive human readable formats like XML. Is it...