flash disc

Share file from Windows to Mac OS

How to share file from windows to Mac

If you are working on windows and you want to share the file to mac, follow this simple steps to get the work done.

The first is to go to your mac and enable the file sharing. I would do this temporarily so that it won’t be opened all the time, this is for security purpose

How to allow sharing file in mac

  1. Go to  settings in mac
  2. Go to sharing
  3. Check the file sharing options

How to connect to mac from windows.

Before you do this, you will need to get the ip address of the mac computer that you will be using it later in windows connection.

How to get IP address of the the computer on mac

Open a terminal using either of the following methods:

  • Go to finder
  • Select Applications under favorites, if you don’t see it, go to finder menu on the top next to the apple icon while the finder is active, select preferences and check Applications
  • In the applications, go to Utilities and select terminal


  • Hold command and hit space
  • type terminal
  • select the terminal

Once you get the terminal in either ways, then type the following command in the terminal


From the result, look for inet and that shall be your ip address ( this time it has to be the local one)

Connecting to mac from windows

On windows, on the search bar, type run

When you get the input box type \\ip-address-here

This creates anther window where you have to enter the username and password of the mac computer. That will connect you to the mac computer.


Cannot read property setState of undefined

This will be a very quick guide for the above error.

This is common to have on the react using class or stateful component.

Take the following example

import React, {Component} from 'react';
class App extends Component {
    constructor() {
        this.state = {name: "default"};

    keyHandler(event) {
        this.setState({name: event.target.value})

    render() {
        return (
The name is {this.state.name}
<input id="name" onKeyUp={this.keyHandler} /≶
); } }

if you have something like the above one, where you haven’t bind the method to the class, then the error will happen.

Just adding

this.keyHandler = this.keyHandler.bind(this);

in the constructor will handle the issue.

spring framework show sql parameters

See the binding parameters in JPA query – java logs

see binding parameters in jpa query

What would the world look like if log was not created for us – I ask, and you say nothing! You right, there is also another world :)

Getting back from the crazy thoughts, there is a config spring allows us to see the SQL statements that the JPA is doing behind the scenes..

In you application.yml file


Will show the sql statements on your logs. But it will show with ? for the values used.

To see those values also along with the query add the following on the application file.


That is it!

create tables hibernate

Hibernate Not Creating table from Entity – Java Issue

Hibernate not creating table issue

All was fine until one table was not creating on the final destination of postgres database.

There was a lot of tables I was expecting to be created and only one was not making it.

How to debug the issue

The first thing you want to do is to see the all SQLs that are being created by Hibernate


You can put the above in the application.yml file and just keep an eye when the logs are rolling.

I see the create statement there

Yup, I was able to see the table being created in the logs. So why doesn’t it show up on postgres database??

The issue was one of the columns that I used was named as start, end, status..

I just changed those to other property names and the problem got resolved.

The other way you can do is to leverage the usage of Column annotation and provide the name right there. That way Hibernate will get better understanding of what is going on.

Hope it helps.

longest word in the sentence

find longest word in the sentence

Find the longest word in the sentence

I am using javascript for this question.

It can be done in a lot of ways. The straight forward way could be the fastest probably. You will loop over the array of the words – you can split it with space – ” “.

Then just compare the value of the word length with maximum value and overwrite when it is higher – you know what I mean..

I will show the single liner for this though

var longestWord = "Guess what the longest word in the dictionary is".split(" ").sort(function(a, b){
    return b.length - a.length;

Let’s go through what is going on..

The first part "Guess what the longest word in the dictionary is" is the given example sentence we are trying to find the longest word for.

Then we split the string into array of words using the split(" ") function. Now we have array to work with.

Then we sorted the array with sorter function passed to it. Sorter function in this one is anonymous function that we pass to it.

Finally we just took the first element of the sorted array which is sorted by the length of the word.

Also with the same concept, we have have it using reduce function;

"I still am having the wonderfulness of this thing ".split(" ").reduce((word1, word2) => word2.length > word1.length ? word2 : word1 );

That is it!

Max string character counting

Get maximum occurring character

Find maximum occurring character from the given string

Max occurring character is the most frequent interview whiteboard question. Ok, there are so many of ways to handle this question and this is just one of them.

I have showed it with 6 characters as starting point and use those as reference. But you can extend that given object to hold as many characters as you want.
Continue reading Get maximum occurring character

Flatten nested javascript array

How do you flatten array in javascript

If you are given an array that contains literals, arrays and objects and you want to get all the values to one array.

Here is the snippet using recursive function to attain that.

function implode(arr) {
	var res = [];
	for (var i =0; i < arr.length ; i++) {
    	if (Array.isArray(arr[i])) {
        	res = res.concat(implode(arr[i]));
		} else if(typeof arr[i] == 'object' ) {
			var values = Object.values(arr[i]);
        	for (var j = 0 ; j < values.length ; j++) {
            	if (!Array.isArray(values[j]) && typeof values[i] != 'object') {
                	res = res.concat(implode(values[j]));
		} else {
	return res;

javascript queue and stack implementation

Implement Queue Using two Stacks – JavaScript algorithm

Using stack data structure to implement queue in javascript

This is one way of implementing of the stack to be reused as queue using two stacks.

You may complain you are abusing the memory. But we are not copying the data on both stacks we are using the stacks for switching values only

            class Queue {
                constructor() {
                    this.inputStack = [];
                    this.outputStack = [];

                enqueue(item) {

                dequeue(item) {
                    this.outputStack = [];
                    if (this.inputStack.length > 0) {
                        while (this.inputStack.length > 0) {
                    if (this.outputStack.length > 0) {
                        this.inputStack = [];
                        while (this.outputStack.length > 0) {

                listIn() {
                    let i=0;
                    while(i < this.inputStack.length) {
                listOut() {
                    let i=0;
                    while(i < this.outputStack.length) {

*There is part left out for improvement and refactoring. But, can you see a way to use only one while rather than two whiles and make it a bit efficient?

node js on mac machine

Update Node and npm on mac OSX

How to completely remove Node and reinstall it

It might be a bit annoying to uninstall stuff. But sometimes you gotta do it.

To uninstall node completely from your machine:
brew uninstall --ignore-dependencies npm

This will handle the issue you may have with dependencies. If you have other modules like yarn or jhipster on your machine, they are dependent on node and uninstalling might not come easy.

To uninstall node in a more aggressive way:
rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/npm*

how to install node, npm (node package manager) on Mac OSX

It is rather simple. Just go to https://nodejs.org and download and follow the steps.

ssh tunneling to aws instance

Tunneling to AWS instance using pem file

How to tunnel to bastion instance using ssh tunneling

Usually you are going to need this on jump server or what we bastionwhitelist your IP to the corresponding server before you attempt to ssh tunnel to it.

How do I do that?

Go to your terminal and issue


What is happening?
You will get your pem file and use that as a token to jump to your server. In this example I gave and RDS of mysql which by default has port of 3306. And I have given 3308 which will be used from my machine to jump to the server as needed.

what then?

Now, your local machine is configured to relay – forward – the port to the destination and whatever you throwing to your local machine’s 3308 port will be forwarded to the remote servers port and you can access the RDS.