Sunday, May 28, 2017

Zero MQ : implementation of Publisher/Subscriber model using node

Zero MQ is a very easy technology to implement various message passing technology. Here I am trying to implement one of most common pattern Publisher/Subscriber model  with  Node JS and Zero MQ .

In Publisher/Subscriber model , Publisher (server) publish a message , and number of client that can subscribe it to it.

Before starting to code , Plz go ahead and intall zmq in your machine . You can follow step by step command in the below github gist
https://gist.github.com/cdjhlee/b8e3c927a01b0948b42d

Next you need to install zmq node module in your machine. I have installed it "globally" .

Let now , begin our Publisher. Here in the below code our Publisher is constantly watching a file and send a message when it find that file has been change. Let assume the file name is "pub.txt".

Here I have added the fs.watch function that monitor the change in the above file and send message to all the connected client when there is change in file.So when ever u want to trigger a message all u need to make change in pub.txt file.

I have written 2 subscriber one that subscribe to cat and other to dog. Now when the server , send the message . The respective client capture the message and print it to console.





Thursday, May 25, 2017

Node JS : understanding the event loop in Javascript.

Most of the time , JavaScript developer have the confusion around the concept of event loop. How event loop , libuv and Google V8 interpreter works  together that make JavaScript I/O non-blocking and asynchronous.

Most of us will one-way or other , has/have encountered the question in the interview or have been asked to explain the event loop or asynchronous concept in small JavaScript script with "setTimeout" function with a callback.In many ways , the concept of event loop is a kind of  hard shell to crack for people coming from different programming background.

Recently I came across , Philip's lecture were he has not only explained the flow of code from stack , to callback queue to event loop  successfully but also demonstrated it very well.
He has even develop small tool to give demo of event loop flow and how various component of Javascript interact with each other . http://latentflip.com/



Hope the above lecture will able to clear the confusion surrounding  the concept.

Tuesday, March 14, 2017

Study Less, Study Smart

If you spend hours and hours of studying, without improving your grades, or information retention, then learn how to study smart by Marty Lobdell. Lobdell taught Psychology at Pierce College in Washington State for 40 years. During Lobdell's career, he has taught tens of thousands of students and he wants students to succeed. After watching students cram for eight hours or more for a test without any improvement, Lobdell has developed a studying technique that helps the brain retain the information that you are studying in this video "Study Less, Study Smart"





Wednesday, January 25, 2017

Which of the following two passwords is stronger?



Which of the following two passwords is stronger,
more secure, and more difficult to crack?
D0g.....................
PrXyc.N(n4k77#L!eVdAfp9

If you really want to know you need to check the gibson password brute force search calcultor. Most of the website are password strength calculator. Check out the website https://www.grc.com/haystack.htm

Sunday, January 22, 2017

nodemon : must have tool for node js developer

 Some of the tools we have make developer life easy. If you are node js developer and writing any server app , you must install this small command line tool . It will make ur life dam easy.

The tool restart the server as soon any files are modified. So life become bit easy.For more details check the nodemon website. 

Wednesday, January 18, 2017

Web security : tool that u can make use to test your website


It important for a web-developer to know kind of attack malicious people make use to do damage to your web site.

You can easily visualize how these attack is being used for some of the world biggest data breached
Check the information beaches around the world http://www.informationisbeautiful.net/visualizations/worlds-biggest-data-breaches-hacks/


some of the common one are

1. SQL injection.  here I will discuss error based sql injection.In these attacker try to modify the serach query in the url and then try to get the error and next he will modify the query to get output they you does not want to desirably want to share on the web page.

The easier way to make user of automated tool "Havij". Plz explore it to validate to test your website.
Make sure validate the data getting as external input eg if u are expecting number .. then it should be number in thr post and get request.
The other best way to get stay away from SQL injection to make use of binding variable  (parameterize queries) in query that you are making use having the input from the outside.
The last one is allow application to have access access to certain table with "principle of least permission". Eg should ur application db account , can run database admin command".
Last one but important is web application firewall and cryptographic storage.



2.  Insufficient Transport Layer Security : it  mean here that are you making lack of making secure layer (eg http or https) while communicating to web server on internet.Most people get hacked when they using open wifi network. Here , attacker may monitor the information in and out flowing through the router. Some attacker even modify the DNS server setting for common ip request to their own hosted website with replicated page.
Some times attacker inject the key loger js script into the page. So how to prevent such attack.
Make sure that you web application login page open in https mode along with https post form is used.So apply TLS to encrypt by default (U need to pay some money to get the certificate) if you are expanding your application especially for the login page authentication.

Also make use of encrypted authentication cookies in your application and firewall is the last defense.
Also check out out the blog how to setup SSL certificate.
https://ksylvest.com/posts/2014-05-06/setup-free-ish-ssl-tls-on-heroku-for-ruby-on-rails-or-any-other-framework



3. Insecure Password Storage
I hope very developer  is aware of rainbow table.Here the attacker has pre-computed hash table that he make use of guess the password. Easiest way to prevent , to make use of bcrypt algorithm (avoid md5) and save password and random salt used , save  in two separate column. You can add additional layer of security by encrypting the output from bcrypt again using md5.
 
eg
byscript alogorithm -> random salt + password -> md5 -> save salt column and password column
I future I may be sharing , how to implement the above in node js

4. Cross Site Scripting (XSS)

5. Weak Account Management


Tuesday, July 26, 2016

interview details for Perl/ Unix developer @ deutsche bank

Recently I had interview @ Deutsche bank for perl developer.

I would like to share , though most of the question where pretty basic , few added my learning. :)


Friday, February 19, 2016

Perl problem of the ziprecuiter while submitting the application

Recently I had chance to apply for the zip reciter (USA base startup.)
While application you are asked to resolve a problem in perl or Phython.


Here the description of the problem



Though when I submitted the application , I did not thought and made used of JSON module.
But I think , It can be solved too without module , as it an ref to array.



Tuesday, March 24, 2015

Perl and selenium - a trail of youtube history


Recently I wanted to to get complete list of the youtube history page to a video I have seen a long time back. Though Youtube save ur maintain ur history but does not provide the option to search your history. The history button provided shows very few videos at time.

So I decided to write my own script recipe to handle this scenario. Though I have know about selenium for along time but never tried it Perl API. Let see it this can help me to get my list.

 Before reading this script recipe u need to check some info video and slide share get the functionality and usage the module (ingredient) we will going to use 

Friday, February 13, 2015

simple usage Time::HiRes of the 'for execution time of child process

Hi All

some times we are required to control the time execution of the child sub program. This can be achieved use the  Time::HiRes



I have added the code snippet. Here  I have line the main program (line 9 ) to sleep for 30 sec.
But setup alarm timeout to 3 sec (line 4)  and trigger timeout after 3 sec and setup local variable $SIG{ALRM} to time out/

Thursday, December 4, 2014

flock - All u need to know abut file locking in perl




Some times we need control over  read and write over files operation. File locking comes for rescue.

Though Perl provide many function to control over  file locking operation. I found flock function is the best.

Perl monks has a great tutorial for flock and operation and usage . Simple usage  and operation number and their meaning.


  sub LOCK_SH { 1 } ## shared lock
  sub LOCK_EX { 2 } ## exclusive lock
  sub LOCK_NB { 4 } ## non-blocking
  sub LOCK_UN { 8 } ## unlock 





Sunday, August 10, 2014

all u need to know about perl unit testing

Hi
I have been using Test::Simple, I always wanted to know about Test::More

In the below talk James has been able to easily capture all important modules and function offered by them especially ok, is,  and like

Check out the video , 56 min worth spending :)


 

Thursday, June 19, 2014

RESTfull Love service Triangle

Hi All ,

 Today I will be writing little about RESTful api (Represntational state transfer) , kind of web service.Now day every  application (generally mobile application) and good website will provide one
of these services to the programer to interact more and develop application on top of it.





 So to start with REST u should be knowing these 3 terms (mug it) (also REST triangle)
1. noun
2.verb
3.content-type

In rest , noun is URL identifier (eg. www.example.com ).
Verb   is the action to be taken HTTP request method eg GET to read , POST to create, PUT to update and DELETE to delete.

Wednesday, May 14, 2014

Why I have started prefering viber over skype on my linux box for messaging!!

Recently , I installed the viber on my linux machine (ubuntu 14.04) for my development box just enthusiastically and found the above my expectation  as compared  skype linux version.

Lets begins with the login , where I used my mobile no and it automatically synced my login to mobile contact. So for now onward I am getting into habit of messaging my friends on viber in place of whatsapp. That is a huge gap in skpye,  which identification element is your mail/ facebook login.

Next comes the gui, the gui of viber for the linux flavour is more friendly intuitive. I do not think any one will disagree on this (again I will highlight I am the linux version).

What left me in miserable state while using viber was about the call quality. I cant neither hear sound or my mic is working for viber , that is not the case for skype. (bug)

 Hope , viber development team will soon be resolving these issue.

Saturday, April 12, 2014

SQL Fiddle - Cloud way test your query and schema.




Most of the times, we are in need to validate our query with the test data for validation purpose and proof of concept.
Recently I came across the SQL Fiddle and got hooked to it to validate my query to match the expected results.

SQL Fiddle not only provide list of database including oracle and also a new cloud base tool to validate your query and sharing your schema over various forum


Tuesday, April 8, 2014

Overriding the core function/ subrotine in perl

Though its not recommended but some times we are in need to change or extend the core functionality of inbuilt Perl function/ subroutine.

This can be easily implemented in the following way. I have created a small gist for changing the core functionality.( Just for fun)



You can read it more in perdoc .

Tuesday, March 25, 2014

Interview experience for perl developer with booking.com

Recently I had an opportunity to give the interview for booking.com for perl developer.

I got the call from the HR after 2 week from the CV submission date. Initial HR round was very simple . Introduction about the company and kind of work you are expected to do, the team strength etc

The online interview with the technical people was arrange after 2 people with 2 perl developer. The interview was about perl.

Saturday, March 8, 2014

Learning the SQL by practising online - SQLZOO




SQL is standard language to access and manipulation data in MySQL and Oracle.

Although SQL is quite easy to learn and has limited syntax, but the concept of using mainly DDL (Data Definition Language) ,DML (Data Manipulation Language) and DCL (Data Control Language) take time to understand or to get accustomed to make use of  when it is required. (ref)

As far as , Learning SQL and grasping the syntax may be quite easy to begin with (lot of online resource are there) , but to get the required data for the  real world problem might be not that much easy and may require practice.

SQLZOO is website where you have opportunity to practice these problem, to sharpen your skill and to test what you have acquired. The best thing of this website , it support all type of database engine (Oracle, MySQL etc) and has many problem to practice.

Problem start with a scenario and will ask you to use specific DML , to get the required results.

Great website to start with your SQL training and hone your ability.

Wednesday, January 1, 2014

tosdr.org - a new initiative to explain the goods and hidden bad in the service terms you are signing




Now day We are signing new account now and then.  Each service provider has it own sets of "term of service". These terms are bulky and  usually ignored by the end user before signing.

Now a new initiative called tosdr.org, can help know the goods and hidden bad in simple layman terms about the service , you are about to signed or have signed already. They have simple rating system very good A to very bad (E).