Tuesday, June 21, 2016

Setting up git on window machine

I am trying to setup git on my windows machine and trying to connect to bitbucket.org to access repository.

When I am testing the connection I am getting the error


harvey@HARVEY-L MINGW64 /d/HarveyGitTest (master)
$ ssh -T git@bitbucket.org
Warning: Permanently added the RSA host key for IP address '104.192.143.2' to the list of known hosts.
Permission denied (publickey).

harvey@HARVEY-L MINGW64 /d/HarveyGitTest (master)

What is going on here ?

I will give you a background before I move ahead. I have installed 64bit git client for windows and using its command line.

The command line opens using Git Bash utility.

The problem is that I need to add my local public key on to bitbucket.

1. Generating ssh key pair

Open another session of Git Bash and

cd .ssh

see if you can find id_rsa and id_rsa.pub file.

id_rsa -->> This file if exists contains my private key
id_rsa.pub -->> This file if exists contains my public key

In case the files do not exist then generate them using command

ssh-keygen -t rsa

and then follow the prompts. Now you would be able to see both of these files id_rsa and id_rsa.pub.

Now get the contents of id_rsa.pub using

cat id_rsa.pub

copy the contents and then go to bitbucket.org

On right side click on your icon >> View Profile.

you will see a button "Bitbucket Settings" under there on the page, click it.

One the left side click on SSH Keys >> Add Key

Enter Label and paste the key and click Add Key to save it.

Now go back to Git Bash where you were getting the error and run the command below:

 ssh -T git@bitbucket.org

harvey@HARVEY-L MINGW64 /d/HarveyGitTest (master)
$ ssh -T git@bitbucket.org
logged in as harv.

You can use git or hg to connect to Bitbucket. Shell access is disabled.

harvey@HARVEY-L MINGW64 /d/HarveyGitTest (master)

Enjoy!!!



Sunday, June 19, 2016

Simplest way to setup WiFi on Raspberry PI using command line

Most of the time we access Raspberry PI from command line and in this case if we have to connect PI to a network then it might be bit tricky. The easiest way is to modify the file and add bits from network.

In our case the SSID is TestWiF, the password for the wifi is P455WOr6 and key_management is WPA-PSK

pi@raspberrypi:~ $ sudo cat /etc/wpa_supplicant/wpa_supplicant.conf 
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=GB

network={
ssid="TestWiFi"
psk="P455WOr6"
key_mgmt=WPA-PSK
}

pi@raspberrypi:~ $ 

Once the modifications are done just restart the PI


pi@raspberrypi:~ $ sudo shutdown -r now

Thursday, June 16, 2016

Test SQL Server database connectivity from local machine

Simplest way is create an empty file by right click and new . Name it to something .UDL

Now double click on it and it should open something like below now enter the details and test connection


Wednesday, June 1, 2016

In sqlite re-organizing the database

SQLite is like a big file and has tables inside that database file. Some times there is a need to delete a large number of records from the table in that case the records are deleting and leaving empty pockets behind in that large file. After the deletion the file size still remains same.

But there is a way to reduce the database file size and that can be achieved using a command VACUUM;

Below is the example on sqlite to reduce the size of database file to what is used and omitting the blank pockets out.

$ ls -l
-rw-rw-r--  1 rag rag 1627136 Jan  1 15:00 templog.db
$ sqlite3 templog.db
sqlite> . timer on
sqlite>
sqlite> vacuum;
CPU Time: user 0.360000 sys 0.250000
sqlite>
$ ls -l templog.db
-rw-rw-r-- 1 rag rag 399360 Jan  1 15:15 templog.db

you can see that the size of the database file is reduced to what is under use at the moment.