Monday, February 4, 2019

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


Assumptions:

-  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" ubuntu@ec2-13-23--123.us-east-2.compute.amazonaws.com -L 3307:127.0.0.1:3306 -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

[L]
- 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

Demo
Counting with a local variable.

0


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



h2.top-triangle:after { 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!!  ( https://github.com/munawer-t/bar-chart-using-pure-css3-and-angularjs )









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
    [mysqld]
    sql_mode="STRICT_ALL_TABLES"
 If you want strict mode with full group by use this
[mysqld]
sql_mode="STRICT_ALL_TABLES,ONLY_FULL_GROUP_BY"

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'
OR
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]




:)