Monday, February 4, 2019

How to access mysql installed on your EC2 instance from your local mysql client (sqlyog ..) [ssh tunnelling]


-  You have access to EC2 instance with ssh key pair (.pem)
-  Mysql server is installed on you EC2 instance which is up and running
-  You should have one mysql user with all necessary privileges

Create a ssh tunnel on Mac os or linux:

Open command prompt and run below command from your terminal:

ssh -i "My-key
.pem" -L 3307: -N

[My-key] - Point where your key pair is located

[3307] - Changed the port from 3306 to 3307, in case if you have mysql server already running locally on default port

- Binds local port to remote host port

[N] - Means forwarding ports

Connect to remote mysql using client:

Here I am connecting with sql yog:

Tuesday, June 9, 2015

Search a file with matching a pattern under directory in linux, unix ..

Run this command
grep -H -r [pattern] [directory]

 pattern - Replace this with your custom patter
 directory - Replace this with your custom patter
-H : means to print the filename for each match.
-r : Read all files under each directory, recursively;

Tuesday, February 24, 2015

Javascript closure simple example snippet

Counting with a local variable.


Wednesday, January 7, 2015

How to make triangles or arrows using css border width

h2.entry-title { position: relative; }
h2.entry-title:after { content: ""; border-width: 15px; position: absolute; left: 179px; top: -4px; border-style: solid; border-left-width: 0; border-right: 15px solid green; border-left: 15px solid yellow; }

with all borders

h2.left-triangle:after { border:15px solid transparent; border-right: 15px solid green; }

left triangle

h2.right-triangle:after { border:15px solid transparent; border-left: 15px solid green; }

right triangle { border:15px solid transparent; border-bottom: 15px solid green; }

top triangle

h2.down-triangle:after { border:15px solid transparent; border-top: 15px solid green; }

down triangle

Monday, September 1, 2014

Barchart using css and angularjs

Recently, I came across situation like generating a dynamic graph shown in screen-shot below. I have searched a lot for any javascript api to generate graph/chart like google chart, chartJs etc. But failed. Later decided to develop it with myself using css and angularJs, here is the github code, fork it and contribute :) happy coding!!  ( )

Friday, July 12, 2013

How turn on sql_mode to stric in mysql

1) Edit my.cnf
For Debian :
located at /etc/mysql/my.cnf , add to my.cnf
 If you want strict mode with full group by use this

2) Restart mysql

3) Check it by running this query
SELECT @@GLOBAL.sql_mode;
Note: If you want turn off strict mode on run time just run this query
SET @@global.sql_mode='STRICT_ALL_TABLES'
SET @@session.sql_mode='STRICT_ALL_TABLES'
Thats it.

Wednesday, March 27, 2013

Working with GhostScript : Convert PDF to images using ghostscript

Ghostscript is an interpreter for PostScript™ and (PDF) files, lets see how we can use it convert PDF to images.

-Install Ghostscript (I am using ubunutu, so I can perform)
sudo apt-get install ghostscript

- run these script via console to make images from pdf

gs -dUseCropBox -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -dAdjustWidth=0 -dNOPROMPT -sDEVICE=jpeg -dSAFER -dBATCH -dNOPAUSE -r140 -dJPEGQ=80  -dFirstPage='1' -dLastPage='8' -sOutputFile=/tmp/output/image-%d.jpg /tmp/downloads/sample.pdf

You can see output like this :

and your output folders will list your images :

FYI - Params :
-dFirstPage and -dLastPage specifies page limits , which is optional
-sOutputFile [output file] [input file]