Skip to main content

Posts

Showing posts with the label Technology

Did Snapchat CEO's comment on India being a poor country?

I would like to get the facts straight over here before we get more offended reading the headlines of all the major Indian bulletins. Lets breakdown this incident: This is an allegation. There are no evidence yet to prove this yet. The allegation is made by an employee of Snapchat, Anthony Pompliano, who is currently engaged in lawsuit against Snapchat, accusing the company of misleading the investors by providing inflated statistics about user data. Snapchat unredacted lawsuit by gmaddaus on Scribd According to the allegation, the statement was told in answer to a private company meeting, discussing the further expansion plan. India was ranked 126th in the world richest country. Total countries are 189. The ranking was created by adjusting GDP per capita to relative purchasing power.  Snapchat is a business. It earns money from advertising. The digital advertisement market of India is close to   Rs 7000 crore  . Which roughly comes to $ 1 billion whi...

Fixing Deployment.AddInAlreadyInstalledException.

If you are building any VSTO for any of the office applications, then its quite common to run into this issue. The error message would say that "The customization cannot be installed because another version is currently installed and cannot be upgraded from this location. To install this version of the customization, first use Add or Remove Programs to uninstall this program: TestUpdatedVersion. Then install the new customization from the following location: file:///D:/Samples/TestUpdatedVersion/bin/Debug/TestUpdatedVersion.vsto ********** Exception Text ********** Microsoft.VisualStudio.Tools.Applications.Deployment.AddInAlreadyInstalledException: The customization cannot be installed because another version is currently installed and cannot be upgraded from this location. To install this version of the customization, first use Add or Remove Programs to uninstall this program: TestUpdatedVersion. Then install the new customization from the following location: file:/...

How to access banned sites in India?

Today lots of ISP's have banned tonnes of site in India. But they can still be accessed. There are various options to do that: 1) If its a page without media, video content, then search it on google, press the down arrow below the search result, and select cached. This would display the cached result of the page as stored in google. 2) Use a set of proxy server from here . 3) Go to https://www.proxysite.com/ and start accessing websites from there. Happy Surfing!

Linkedin Status Update Image not displayed

I was facing this problem when I was updating images from my site on linkedin. I even asked a question on stackoverflow ( When using linkedin share api submitted-picture-url or sharing url via linkedin, particular url format doesnot work? ) but never got a good response. After that I did lots of experimentation to figure out few things about linkedin in status update image url. I would list them out below: Max size for image should be 100 MB (read somewhere, have not tried it myself.) Linkedin caches the images on its server for 7 days. So if the image on the url shared have changed, linkedin won't update it. A good workaround is to add a query parameter to the image url with some random string of the timestamp while sharing. So, this would make each image url unique. Set the correct mime-type on the servlet serving the image. I was using cdn and with my servlet acting at a proxy to cdn to serve the image. In the process I was missing out the mime-type in the response head...

Email Validation Jquery Plugin.

Recently I wrote a jquery plugin which would allow you to validate an email address for: Syntax checks (RFC defined grammar)   DNS validation Spell checks  Email Service Provider (ESP) specific local-part grammar (if available)  MX  Validation . Free Email Service Check Disposable Email Service check. Sanatize email id based on service provider. In future, I am planning to incorpoprate: Corporate Company details. If you have any suggestion then you can comment.  You can download the plugin here . Try a demo here . Some screenshots of the demo are: Media mention:  Its featured in  10+ Newest Free jQuery Plugins For This Week #16 (2015)   In  10+ Newest Free jQuery Plugins For This Week April #10 (2015) In  4月份本周超过 10 款最新免费 jQuery 插件 In  4月份本周超过 10 款最新免费 jQuery 插件

How to set Tomcat 7 source level to Java 7? Avoid "Resource specification not allowed here for source level below 1.7" error

I have been facing problem where whenever I was accessing jsp page which were using some Java 7 specific features, the compilation of such JSP pages use to fail with following error: Resource specification not allowed here for source level below 1.7 To fix this I googled for hours and set up the JDK home correctly on my catalina.sh with env.sh to point to jdk7. But this never solved my problem. Finally today I hit the gold while reading the apache tomcat jasper  documentation . The JSP compiler had to be set to use 1.7 as target and source version. To do this we need to add two extra init-params in the conf/web.xml file in the tomcat home.  The JSP servlet configuration should have      <servlet>         <servlet-name>jsp</servlet-name>         <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>         <init-param>     ...

Making Twitter Media Upload Api work with Java

I was trying to upload an image and do status update on twitter using there api version 1.1. For this I was using media/upload.json  . I was trying to send content of files as base64 encoded string and setting the appropriate content-type and content-transfer-encoding. But this didn't work. I was getting errors like: 1) Missing paramter media 2) Could not authenticate. My main reason to use this approach was I was getting image url and didn't wanted to save it into a file. But this never worked, then I took a different approach of saving the imageurl into a file and doing a multi part upload. Code for it is below. Hope this helps someone. private String uploadImage(String imageUrl) { File f = new File("/tmp/twitterUploadImage_"+StringUtil.encodeURL(imageUrl)); try { FileUtils.copyURLToFile(new URL(imageUrl), f); } catch (IOException e) { logger.severe("Failed to save image in a file"); return null; } U...

How to run npm installed components from commandline in Windows?

When you are working with windows and nodejs, then you might face this problem, whatever npn packages you install might not be accessible through commandline. By this I mean, is that, suppose you did: npm install -g bower And then executed : bower install Windows might give you an error that 'bower' is unrecognized. A solution to the problem is to add npm global repository to your system path. To do so execute npm config get prefix To get the npm global repository path. Copy this path and follow following steps to add to windows path: On your computer, select  Start->Settings->Control Panel->System : A "System Properties" dialog box will appear. Click it's  Advanced  tab: Click the  Environment variables  button: An  Environment Variables  dialog box will appear. In the  System variables  section, scroll down until you find the  PATH  variable. Select this variable: Click the ...

Zopper Programming Assessment Problem 2 with solution

This is the second problem from HackerEarth that I tried for the friend for interview: Problem: HackerMan says that 5 and 8 are smart digits. A positive integer is called a smart number if it has only smart digits in its decimal representation. HackerMan has three sets of numbers. And he needs your help to find out the number of distinct smart numbers that he can make using one number from each of the three sets. You have to help in it Note:  You must not count the same smart number more than once. Constraints The three sets will contain between 1 and 50 elements, inclusive. Each number in the three sets will contain numbers between 1 and 30,000, inclusive. Input Format The first, third and fifth lines will contain a number N that will specify the count of numbers in the sets on the second, fourth and sixth lines of input. The second, fourth and sixth line will contain the three sets of numbers respectively. Output Format Print a single line containing the ...

Zopper online assesment question on HackerEarth with solution.

Recently a friend asked me to solve a problem which he got on one of the interview, online assessment test. I decided to document my solution here. The companies name was Zopper and the question was asked on the initial online screening test on HackerEarth. Problem: HackerMan says that 5 and 8 are smart digits. A positive integer is called a smart number if it has only smart digits in its decimal representation. HackerMan has three sets of numbers. And he needs your help to find out the number of distinct smart numbers that he can make using one number from each of the three sets. You have to help in it Note:  You must not count the same smart number more than once. Constraints The three sets will contain between 1 and 50 elements, inclusive. Each number in the three sets will contain numbers between 1 and 30,000, inclusive. Input Format The first, third and fifth lines will contain a number N that will specify the count of numbers in the sets on the second, fou...

Breaking open https://web.whatsapp.com/

Today whatsapp have launched an online/web version of their overly popular smartphone messaging app. I was very much interested in seeing the architecture of this app because as far as i knew, they never stored messages on their server but all the data was only stored in users phone. So I started to look under the hood of the webapp and what I saw was a beauty. First let me list down the frameworks they have used in creating this app: React .js : A JAVASCRIPT LIBRARY FOR BUILDING USER INTERFACES from Facebook. Underscore.js  : Unerscore is a JavaScript library that provides a whole mess of useful functional programming helpers without extending any built-in objects. It’s the answer to the question: “If I sit down in front of a blank HTML page, and want to start being productive immediately, what do I need?” … and the tie to go along with jQuery's tux and Backbone's suspenders. Velocity.js : Velocity is an animation engine with the same API as jQuery's $.animate(...

Understanding Code Execution in Javascript

If you are doing any form of programming in Javascript then understanding its eventloop is very important. Any javascript engine has three kinds of memory models: Stack, which has the current function pointer an gets executed sequentially. Heap, this stores all the objects, functions basically anything that is initiated is stored here. Queue, all things to be executed is stored here and stack picks up tasks to do from the queue. So, to understand this further, when a function is getting executed its loaded in the stack and if it encounters any setTimeouts then it would be added in the queue and when the current stack gets empty then the new function to be executed from the queue. This code run will explain the process: console.log("Add this code to queue"); setTimeout(function() {                                                //This goes and si...

Inbox From Google: Review

In an another attempt to reorganise the way email communications work Google has come out with Inbox . Here, google has attempted to use machine learning and nlp for better organise email with a more intuitive UX. I believe this time they have utilised there learnings from Wave failure and have not attempted to change the core email component. But as people are slowly getting use to the timeline kind of UX, they have attempted to preserve that in email and top it up with the new features which they have always wanted to try but restricted by the plain UX of email, like "See pull request", "See flight status." Moreover, seems like this being designed specifically for phone devices. Lets see how useful this cool thing becomes. Never the less, please request an invite by sending a mail to inbox@google.com. I have requested mine and write a review as soon as I get an invite . I got an invite and have started using Inbox. I did not find it majorly innovati...

Tuning ActiveMQ for Performance

Recently I needed to optimize our ActiveMQ configuration for performance. Let me explain our deployment, we had a Jetty based Java app with GWT for the UI. We use gwt-ActiveMq with long polling to send messages to the UI. We were using activemq for everything, for out SM design, or async event listener architecture. We have no plans to scale from more then one box and for us the performance is critical. So things done were: Non-persisten messaging. Its atleast 20x faster. This can be achieved by: Set the NON_PERSISTENT message delivery flag on your MessageProducer. Set the  persistent=false  flag in the   element of the  Xml Configuration  or on the property  BrokerService . Remove the network. We used vm:// as transport so that the entire queue is in memory. No need to go over the network as our broker is embedded in the same context as the producer. You would have to change the broker address in the web.xml of the server as you won't ...

How to configure google app engine when your site is deployed on Heroku and uses CNAME for naked domain?

When we configure Heroku App to our domain we configure it using CNAME records. This means two entry in our DNS records, one for naked domain or xyz.com and other for www.xyz.com. Now, if you want to receive mails over email ids configured with same domain with google apps, gmail then you need to configure MX records for xyz.com. Please see the previous post on this topic  . But there is a problem here, as CNAME record has higher priority, your domain wont return MX rule and always return CNAME rule and MX record validation would fail on the Google Domains page. So, how to solve it: Have A records entry if possible, with heroku this is  not possible. Remove CNAME record from DNS entry for xyz.com and configure google domain, naked redirect to www.xyz.com. Remove CNAME record from DNS entry for xyz.com and use Alias from Domian Control Panel. Remove CNAME record from DNS entry for xyz.com and use Domain Forwarding service for xyz.com to www.xyz.com on the Domain C...

Download playlist or songs from 8tracks.

Many times I come across songs on 8tracks which I am not able to find from other sources. Little bit of googling and searching around, I didn't find a reliable way of doing the same. So, I decided to write a script for me to do that. For the benefit of larger audience, I have hosted it on one of my servers. You can access it from: http://beedio.com/8tracks.html Just go there an paste the 8tracks playlist url in the input field and press Fetch. Its a simple Js script which utilises the 8tracks apis to simulate the play of the song and allow a download or play link where the permissions are available. The urls to download or play individual songs would get listed. As it simulates play of song, so this script would take some time to go and fetch all the urls for download. Ideally, one should press fetch and then come back after few hours to the tab to see all the urls in the list. I have tried to follow the norms of 8tracks as much as possible, if any infringement of ...

Simulate the roll of a bias or weighted dice.

Recently I can across this problem and find it really interesting, so i thought why not write a code and share it. There is a probability distribution given for a n sided dice in form an array. Write a code in java to simulate the roll of dice? I came up with a solution initially which I am not proud of involving caching the outcomes and then based on that rolling the dice. But some googling pointed me finally to this Stackoverflow post: http://stackoverflow.com/questions/5850445/simulating-a-roll-with-a-biased-dice Which explains the algorithm for the same: 4 down vote accepted In general, if your probabilities are {p1,p2, ...,p6}, construct the following helper list: {a1, a2, ... a5} = { p1, p1+p2, p1+p2+p3, p1+p2+p3+p4, p1+p2+p3+p4+p5} Now get a random number X in [0,1] If X <= a1 choose 1 as outcome a1 < X <= a2 choose 2 as outcome a2 < X <= a3 choose 3 as outcome a3 < X <= a4 choose 4 as outcome a4 < X ...

Setting up Google Apps to receive emails on multiple domain.

Many times we have multiple domains for our business like domain.in,domain.co.in and domain.com. And our customers usually make mistakes while tying email as mixing up various domain. So, its important for us to receive all the mails on various domains on the same inbox. This can be achieved in Google Apps environment. To do this : Login to the the control panel of google apps   https://www.google.com/a/ cpanel/ Click on the More Controls at the bottom of your page. Select Domains. Click Add a Domain alias. Enter your new domain. Verify the domain. To do this you would have to login with Google Webmaster Tools account and add google app admin as an owner for that domain. Once the domain is verified add the MX Records. In Big Rock I DNS Management control panel I was getting a weird error as conflict with the CNAME record. For this I modified my @ CNAME record temporarily adding * in place of @ and then added all the MX records based on following table and ...

How to convert a Java Object List into csv.

Wrote a general method to convert a List into a CSV file. package com.biplav.utils import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.List; import org.apache.log4j.Logger; public class ObjectListToCSV { private static final Logger logger = Logger.getLogger(ObjectListToCSV.class); private static final String CSV_SEPARATOR = ","; public static String convertListToCSV(List objectList) { if(objectList.size() < 1) { logger.info("No data in the list to convert to CDR!"); return ""; } String csv = ""; T t = objectList.get(0); Field[] declaredFields = t.getClass().getDeclaredFields(); ArrayList useableFields = getUseableFields(declaredFields); csv = getCSVHeader(csv, useableFields,null); csv=csv.concat("\n"); for(T object : objectList) { csv = addObjectValue(csv, useableFields, object); csv=csv.concat("\n"); } ...