Friday, 13 June 2014

Javascript MapReduce tips and tricks

Recently I was using map and reduce functions in javascript for my project. both of them are absolutely amazing. You can use them for different kind of array manipulations. Here I am listing out various use cases with code.
1. Finding unique elements in an Array
var cities = ["bombay", "delhi", "bombay", "delhi", "delhi", "chennai"];

var uniqueCities = cities.reduce(function(p, c){
         if(p.indexOf(c)<0) p.push(c);
            return p;
         },[]);
console.log(uniqueCities); // ["bombay", "delhi", "chennai"]
2. Sum up array of numbers
var foo = [1,2,3,4,5];
var bar = foo.reduce(function(sum, a) { return sum + a; }, 0)
var barOne = foo.reduce( function(sum, a) { return sum + a; }, 1)
console.log(bar, barOne) // 16
here, the second argument of reduce is initial value of sum. If you don't give the second argument at all, it will work here but it may not work in case of complex objects.

...more use case coming soon.

Sunday, 8 June 2014

Zeal : Offline API documentation browser for Linux

Quoted from zealdocs.org "Zeal is a simple offline API documentation browser inspired by Dash (OS X app), available Linux and Windows".

Zeal gives you offline API documentation for most of the Libraries out there like Angular, Backbone, Django and many more. You can check the list on Dash's website

You can easily install on Ubuntu 14.04 by following steps
1. Run following in terminal
   sudo add-apt-repository ppa:jerzy-kozera/zeal-ppa

2. then do  sudo apt-get update

3. and install with sudo apt-get install zeal

After installing Zeal it can be started from terminal by running zeal and add it to to Startup Application.

Right now only version supported is for Ubuntu Linux Trusty (14.04). Zeal is available for previous version but are not supported officially.

Issues and Solutions
  • I faced a minor issue after installing Zeal. I was not able to see main menu on top of it from where you can I found solution at zeal issues . I tried removing appmenu-qt5 package which worked from me. 
  • Every time starting Zeal will show a popup that it's Hotkey is confliting with system's. So I changed it's default Hotkey from Alt + Space to Ctrl + Shift + Space (Synapse is already using Ctrl + Space)

Installing Synapse launcher in Ubuntu 14.04

I recently upgraded from Ubuntu 12.04 LTS to 14.04. I was quite used to of the Awesome Synapse launcher on Ubuntu 12.04. Just press Ctrl + Space and synapse is there to serve you.

Unfortunately Synapse is not directly available through Software Centre in 14.04. But you can install through testing PPA. just follow this steps

1. Open terminal and add the ppa and press Enter

sudo apt-add-repository ppa:synapse-core/testing
 
2. Now update the Software Repository and after that install synapse

sudo apt-get update
sudo apt-get install synapse 
 
That's it. Now enjoy the awesomeness of Synapse.
 

Monday, 26 May 2014

Add Reindent keyboard shortcut to Sublime-Text 3

I like my code to be always properly formatted, which makes it easier to read and understand. I use Sublime-text for coding and it has Reindent feature which can be found at Edit>>Line>>Reindent ,but everybody wants a keyboard shortcut.

Here is how you can add this shortcut in sublime

Go to Preferences>>Key Bindings - User>>

Now add below key value pair to existing json array (mostly it would be empty previously)

{ "keys": ["ctrl+shift+r"], "command": "reindent"} 

My file contents looks like this

[
    { "keys": ["ctrl+shift+r"], "command": "reindent"} 
]

Instead of ctrl+shift+r you can have any other shortcut you like eg. f12, ctrl+r ...

And remember, To make this shortcut work , you need to have syntax highlighter plugin already installed for the programming language you are using.

Thats it guys. Enjoy the beautiful code.

Monday, 24 February 2014

Accessing Guest (VirtualBox) Node.js Application from Windows/Ubuntu Host

If you are running a Node.js Application inside a Ubuntu VirtualBox machine and want to test the same application in any browser inside your Windows/Ubuntu Host OS, then follow this small tutorial. You can even test the application on any other device in same wifi or lan network as your Host/Guest Machine.
The main reasons I wanted this kind of hack is
  • The Guest machine becomes slow and laggy if you start any browser in it to test your applications.
  • Sometime you just want to use CLI 1.
  • Test the Web Application in mobile or tablet device.
I am explaining here the steps to make it work.

Thursday, 20 February 2014

Test WCF Service with WCF Test Client without installing Visual Studio

There are various tools to test WCF services. Visual studio installation comes with default tool called WCF Test Client, which can be run from Visual Studio Command Prompt by typing wcftestclient. Alternatively for VS 2010 you can navigate to C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\ where you can find and open WcfTestClient.exe



Convert Ember.js online guide using Gimli for PDF generation

There are numerous online sources for learning Ember.js but the best one is their guide on official site. Recently I was learning this framework and headed to the guide page. I just wanted to read it first on my mobile or tablet, But the guide is neither mobile friendly nor any PDFs available. But they have full source of their website on github in Markdown.
 

Sunday, 2 February 2014

Pipo Max M8 Pro: Buying Branded Chinese Android Tablet PC from India

Few months ago I bought a branded Chineese Android Tablet PC from India. The tablet model is Pipo Max M8 Pro. It is a 9.4 inch Android 4.2 device priced very reasonably. I bought it for around ₹18000.

Pipo Max M8 Pro
Pipo Max M8 Pro

Friday, 31 January 2014

Setup for Firefox OS Application Development

HTML5 has been in buzz for last few years. Basically It’s the latest version of HTML. It uses a standard code to create online content. But here I’m not going to describe about HTML5.

Firefox OS Introduction:
This post is about setting up environment for one of the emerging mobile Operating system Firefox OS which uses HTML5 for developing Applications. It was started by Mozilla Foundation and earlier named as Boot to Gecko(B2G).

http://upload.wikimedia.org/wikipedia/commons/4/42/Firefox_OS.png

Firefox is based on linux and over that it uses a layout engine called Gecko. Gecko is the application runtime of Firefox OS. Gecko implements open standards for HTML, CSS, and JavaScript. Firefox OS, powered by Gecko engine, runs only websites in the form of apps, known as web apps.

Tuesday, 28 January 2014

Converting CSV to XML and then to C# Object List

Recently I was working on a project where I had to convert a CSV file to XML.
CSV was generated from a database table. Later that XML has to be converted to C# list and used in the project as setting values.

I'll use a sample csv data here that contains information about few students like their roll number, name and marks in various subjects

Create a C# Console application and add csv file in Resources folder. I'm naming it StudentMarks.csv.



Thursday, 23 January 2014

Drive access problem in windows

I have a dual boot Ubuntu/Windows7 laptop. I frequently use both of them. I guess because of that I faced this really bad problem in my windows machine sometimes back. My D:\ drive was not accessible from windows and it was showing this error everytime I try to open it or double click on it. But it was working absolutely fine in Ubuntu.




Tuesday, 21 January 2014

Use Qt Creator as full fledged C++ IDE

 I was putting efforts to learn C++ for so many months but didn't find any suitable IDE on which I can practice. Then few months ago, one of my friend introduced me to Qt Creator, as one of the best IDE for C++. During the free time in this summer I gave it a try and started learning the language with the help of a ebook on this IDE. And surprisingly, I found Qt Creator to be perfect in so many ways. Every feature I was looking for previously, is  available in it.

Even though, Qt Creator is basically designed for development of Qt applications but It has everything to become a full fledged C++ IDE. I tried it on ubuntu till now. It can be installed directly from software Center. Windows version is also available for download on website.

How to use jQuery UI datepicker in Webpage

I was developing a simple java web application where I needed a datepicker. So here is how I used the jQuery UI datepicker in my application.

First you need to include jQuery UI javascript and css in head of your html page.


Play Classic Dave game in windows 7 32 bit using DOSBOX.

Remember the Classic Dave game you might have played more than 10 years ago. That was the first game I played on PC. I liked it a lot. But it's not possible to play Dave directly on Windows 7 32 bit.

Dangerous Dave

Friday, 10 January 2014

Welcome...!!!

Welcome to kushdilip's blog.

My name is Dilip Kushwaha. I'm a software developer at a company in Bangalore, for more details visit http://www.kushdilip.com .

Why I started this blog?
Because I keep on trying various stuff like technologies, apps, softwares, gadgets, DIYs and lots of other stuff. Its difficult to keep track of things we do in this fast paced life. And this blog will help me keep track of experiments I do and want to share with others.

If you want to contact me please leave comments or contact me on twitter @kushdilip or visit kushdilip.com/contact.

Thanks for stopping by. :)