Multiple keyword search in multiple directories bash script

I guess the title is good enough :)
Probably you can do it in single grep command too.. but this way you will play with bash as well..

here is the bash script doing it

 #! /bin/bash
 dirs=(dir1 dir2 dir3 dir4 dir5)
 keywords=(keyword1 keyword2 keyword3 keyword4 keyword5)
 strs=""
 for word in "${keywords[@]}"; do
     strs+=" -e ${word} "
 done
 
 for path in "${dirs[@]}"; do
     dirname="$(basename "${path}")"
     grep -ir --color ${strs} ${path}
 done

Save this as finder.sh
and you can run it as bash finder.sh

, , , ,

Leave a comment

Connecting to Vagrant [PuPHPet] MySql from host

Probably here with – I can’t connect to mysql on vagrant machine or something… yup I have been there
If you are php developer and are using vagrant you would want to use mysql tool to access the vagrant mysql server.
Here is the step by step procedure.
I will assume the PuPHPet configuration
First, get the user which can connect from any host
Log into your vagrant

vagrant ssh

Then open the mysql configuration file

vi /etc/mysql/my.cnf

And update the bind-address part to be 0.0.0.0 this will allow address to be used from any host. If you want to specifically access from some host only, then put IP over there.

Then being in your vagrant machine run

mysql -uroot -p123

This will be depending on if you have provided a password for root the default on puPHPet would ask password so you would have a password
After this allow root user to access everything from everywhere.. or you can create another user and grant that

mysql > GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123';
mysql > FLUSH PRIVILEGES;

Then to make the sql pickup the changes made so far

sudo service mysql restart

Then being on your host machine open your sequel pro – if you are on mac.. or other clients you would use for mysql.
Then
Mysql Host: 127.0.0.1
Mysql user: root
Mysql Password: 123

SSH Host: 127.0.0.1
SSH Username: vagrant – this is the default one
SSH key -> point the key in puphpet/files/dot/ssh/id_rsa
SSH Port: 2222 – this is also the default ssh port forwarding, if you change this change it here too..

This should be it..

, , , , , ,

Leave a comment

Vagrant running slow sites

Using vagrant and running a website from it looks so slow when you access it form host?
Then you are not alone.
Just enable NFS and you would see an increase on performance.

If you are using puphpet, on your config.yaml file under the synced_folder, set nfs to ‘true’. Otherwise on your Vagrantfile, look for nfs and set that to true.

, , , , , ,

Leave a comment

Guest machine entered an invalid state Vagrant error

I used to use vagrant only at work place. But yesterday I upgraded my mountain lion to maverics and my php | ruby setting was jacked up.
I decided to use vagrant at my home as well and got this error.
It appears that I had an older version of Virtualbox and upgrading that helped the problem in no time.

Happy Vagranting

, , , , ,

Leave a comment

soft rlimits too low error on mongo

This is typical memory issue. Are you running a bunch of heavy programs along side? Check how much pages you are loading on chrome even.. and your IDE..

There is a way to add more before you start mongod though

ulimit -n 2000 && mongod

But I am a fan of using the resource effectively by removing apps that takes up my memory..

, , ,

Leave a comment

Installing php-mysql-driver using mysqlnative driver

PHP has been providing us starting form 5.3 the mysqlnd [mysql native driver] that will liberate us from using the mysql client library. And it will be shipped along with the php
But if we remove the mysqllib for some reason and wanted to load it again..
This will be for linux fedora – I have done this on Amazon EC2 server

sudo yum shell
remove php-mysql
install php-mysqlnd
run
quit

you will see the new mysql ini files being added in /etc/php.d folder
Then restart httpd

sudo service restart httpd

, , , ,

Leave a comment

Upgrade mysql 5.5 to mysql 5.6

This would probably make sense on EC2 instance where it comes by default with mysql 5.5

First shutdown the mysql server and then go ahead and move the mysql 5.5 to new folder

sudo mv /var/lib/mysql /var/lib/mysql55

Then grab the tar from Here

Once you download the tar file

sudo tar -xvf yourDownloadedTar.tar
sudo rpm -ivh MySQL-shared-5.6.17-1.el6.x86_64.rpm
sudo rpm -ivh MySQL-client-5.6.17-1.el6.x86_64.rpm
sudo rpm -ivh MySQL-server-5.6.17-1.el6.x86_64.rpm

yup.. that would be it.
Then restart the mysql and it shall be updated

, , ,

Leave a comment

Follow

Get every new post delivered to your Inbox.