Saturday, 24 March 2018

Recover from Git Hard Reset

Hey Guys,

Today we talk about how to recover  from git reset head command.

Sometimes we do git reset HEAD~  to move the pointer to previous commit . 

If we again we want to come back to latest commit or other commits

Do the below

git reflog show    ## display all the commits log with HEAD

git reset HEAD@{1}     ## reset to selected HEAD from above list

Monday, 20 November 2017

Mysql stored procedure to export sql insert statements

DELIMITER $$

DROP PROCEDURE IF EXISTS `InsGen` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `InsGen`(in_db varchar(20),in_table varchar(20),in_file varchar(100))
BEGIN

declare Whrs varchar(500);
declare Sels varchar(500);
declare Inserts varchar(2000);
declare tablename varchar(20);

set tablename=in_table;

# Comma separated column names - used for Select
select group_concat(concat('concat(\'"\',','ifnull(',column_name,','''')',',\'"\')')) INTO @Sels from information_schema.columns where table_schema=in_db and table_name=tablename;

# Comma separated column names - used for Group By
select group_concat('`',column_name,'`') INTO @Whrs from information_schema.columns where table_schema=in_db and table_name=tablename;

#Main Select Statement for fetching comma separated table values
set @Inserts=concat("select concat('insert into ", in_db,".",tablename," values(',concat_ws(',',",@Sels,"),');') from ", in_db,".",tablename," group by ",@Whrs, " INTO OUTFILE '", in_file ,"'");

PREPARE Inserts FROM @Inserts;
EXECUTE Inserts;

END $$

DELIMITER ;


Ref & Credits : http://kedar.nitty-witty.com/blog/mysql-stored-procedure-to-generate-extract-insert-statement

Friday, 9 June 2017

copy-or-transfer- files-from-Mac OS- to-Pen-Drive-or-Hard-Disk-or-USB-NTFS-filesystem

Hey there, 
Thanks to NTFS-3G for making read /write support for NTFS file system .it is an open source cross-platform implementation of the Microsoft Windows NTFS file system with read-write support.
https://github.com/osxfuse/osxfuse/wiki/NTFS-3G
Steps to make it work 

1. Install the ntfs-3g using below 
brew install ntfs-3g
2. Once installation is succesful, NTFS-3G you can manually mount NTFS volumes in read-write mode by executing the below commands in your terminal. 
Get the disks avail in your system using below command in your terminal
        diskutil list
 It will display all the avail disk partitions. so see the disk name of pen drive or USB drive you would like to copy. it can be something like below  /dev/disk1s1 ...
Replace /dev/disk1s1 with the actual NTFS partition you want to mount. You can find the partition name using diskutil list.
sudo mkdir /Volumes/NTFS
sudo /usr/local/bin/ntfs-3g   /dev/disk1s1     /Volumes/NTFS -olocal -oallow_other

You may face an issue like below

Error opening '/dev/disk3s1': Resource busy
Failed to mount '/dev/disk3s1': Resource busy
Mount is denied because the NTFS volume is already exclusively opened.
The volume may be already mounted, or another software may use it which
could be identified for example by the help of the 'fuser' command.



To resolve above please unmount it and do . to unmount disk 

  sudo umount /dev/disk1s1

Thats it . now you are able to copy/paste/delete the files from MAC OS to Pen drive, Hard disk , USb drive