Saturday, August 17, 2013

My MAMP MySql is not turning on!!!!!!!

I have updated my MAMP version to 2.0 and after that my mysql stop working.
This command worked for me and after running the following in my command line it start working again.. :)
     ps aux | grep mysql 
     lsof -i 
     killall -9 mysqld
if needed
    sudo killall -9 mysqld

Using composer with MAMP’s version of PHP

One tool I have been playing with recently is Composer which is a dependency manager, think Ruby Gems but for PHP. Which is a great little tool and I’m really happy to see the community getting behind it and moving forward. After just trying to install composer I ran into a little problem which I thought was worth sharing.
After running curl -s https://getcomposer.org/installer | php, I get the following error:

Some settings on your machine make Composer unable to work properly.
Make sure that you fix the issues listed below and run this script again:

The detect_unicode setting must be disabled.
Add the following to the end of your `php.ini`:
    detect_unicode = Off


Which looks pretty simple to fix but MAMP should have this setting disabled. So I ranwhich php and I’m told I’m running /usr/bin/php which is the version of PHP that comes preinstalled with OS X. So we just need to swap this over to the PHP that is installed with MAMP, which is located at

 /Applications/MAMP/bin/php/php5.3.6/bin 

To do this I edit my .bash_profile or .profile if you are using a different shell and add the MAMP version of PHP to the PATH variable.

export PATH=/Applications/MAMP/bin/php/php5.3.6/bin:$PATH

It’s important to append the existing $PATH at the end otherwise the version of PHP in /usr/bin/php will be found and loaded first instead. Save the .bash_profile and reload your profile by typing

 source ~/.bash_profile

and run which php, and if you’ve done everything right should say /Applications/MAMP/bin/php/php5.3.6/bin/php.

Saturday, June 8, 2013

How to list all CRON Jobs for all user

To have a improved output formatting you can run the following command in you terminal.

for user in $(cut -f1 -d: /etc/passwd)
do echo $user && crontab -u $user -l
echo " "
done

Wednesday, May 22, 2013

Easy way to delete all objects from S3 bucket

I had to delete a bucket from S3 server But the problem is, a bucket can only be deleted if it is empty. Delete objects using User Interface on Amazon S3 management console is a tough job and very time consuming. Take a look at the following screenshot.


If a bucket hold more then 10000 objects then how you will do it?

If you are familier with Amazon SDK PHP2 go with the following code to accomplish this task easily..
require 'vendor/autoload.php';

use Aws\S3\S3Client;
use Aws\S3\Model\ClearBucket;

$s3 = S3Client::factory(array(
    'key' => 'write_your_key_here',
    'secret' => 'write_your_secret_key_here'
));

$bucket = 'your_bucket_name';

$clear = new ClearBucket($s3, $bucket);
$clear->clear();

// Delete the bucket
$result = $s3->deleteBucket(array('Bucket' => $bucket));

// Wait until the bucket is not accessible
$result1 = $s3->waitUntilBucketNotExists(array('Bucket' => $bucket));

Another way to do this..
$bucket = 'your_bucket_name';

$iterator = $s3->getIterator('ListObjects', array(
    'Bucket' => $bucket
));

$s3->registerStreamWrapper();

foreach ($iterator as $object) {
    unlink('s3://'.$bucket.'/'.$object['Key']);
}

Monday, May 13, 2013

How to use JW Player on FancyBox

How I got JW Player working inside FancyBox


    jQuery(".position1").fancybox({
        'content':'
Big Opportunity, Health, Convenience , Trading up – Leah Weckert
', maxWidth:800, maxHeight:600, fitToView:false, width:'70%', height:'70%', autoSize:true, closeClick:false, openEffect:'none', closeEffect:'none', afterShow:function () { jwplayer('mediaspace').setup({ 'flashplayer':'/coles-brand/js/jwplayer/jwplayer.flash.swf', 'file':"http://www.blipunited.com/lb/video.mp4", 'image':'http://img.youtube.com/vi/LtGoBZ4D4_E/0.jpg', 'provider':'youtube', 'height':400, 'width':700, 'controlbar.position':'bottom' }); } });

Monday, May 6, 2013

Install Solr in 10 munite

I am working on a Property Listing web site for long which is based on RETS(Real Estate Transaction Standard). It has more then 300000 listing in total  for single RETS server and planing to added more RETS server in the system. Day by day data(listing) are increasing and the question scalability become more visible.
Solr makes it easy to run a full-featured search server. In fact, its so easy, It can be setup spending 10-15 min..
  • Installing Solr
  • Starting Solr
  • Indexing Data
  • Searching
  • Shutdown

Installing Solr

For the purposes of this tutorial, I'll assume you're on a Linux or Mac environment.
You should also have JDK 5 or above installed.
wget http://archive.apache.org/dist/lucene/solr/3.4.0/apache-solr-3.4.0.zip
tar -zxvf apache-solr-3.4.0.tgz
cd apache-solr-3.4.0

Starting Solr

Solr comes with an example directory which contains some sample files we can use.
We start this example server with java -jar start.jar.
cd example
java -jar start.jar
You should see something like this in the terminal.
2011-10-02 05:20:27.120:INFO::Logging to STDERR via org.mortbay.log.StdErrLog
2011-10-02 05:20:27.212:INFO::jetty-6.1-SNAPSHOT
....
2011-10-02 05:18:27.645:INFO::Started SocketConnector@0.0.0.0:8983
Solr is now running! You can now access the Solr Admin webapp by loadinghttp://localhost:8983/solr/admin/ in your web browser.

Indexing Data

We're now going to add some sample data to our Solr instance.
The exampledocs folder contains some XML files we can use.
A quick glance at one of the XML files reveals that each Solr document consists of multiple fields. Each field has a name and a value. For example:
<doc>
  <field name="id">9885A004</field>
  <field name="name">Canon PowerShot SD500</field>
  <field name="manu">Canon Inc.</field>
...
  <field name="inStock">true</field>
</doc>
The post.sh shell script in the same folder provides a convenient way to add files to Solr via HTTP POST.
cd exampledocs
./post.sh monitor.xml
That produces:
Posting file monitor.xml to http://localhost:8983/solr/update
<?xml version="1.0" encoding="UTF-8"?>
<response>
<lst name="responseHeader"><int name="status">0</int><intname="QTime">89</int></lst>
</response>
This response tells us that the POST operation was successful.
Note that there are 2 main ways of adding data to Solr:
  1. HTTP
  2. Native client
We'll explore these in greater detail in a subsequent tutorial.

Searching

Let's see if we can retrieve the document we just added.
Since Solr accepts HTTP requests, you can use your web browser to communicate with Solr: http://localhost:8983/solr/select?q=*:*&wt=json
This returns the following JSON result:
{
    "responseHeader": {
        "status": 0,
        "QTime": 0,
        "params": {
            "wt": "json",
            "q": "*:*"
        }
    },
    "response": {
        "numFound": 1,
        "start": 0,
        "docs": [
            {
                "id": "3007WFP",
                "name": "Dell Widescreen UltraSharp 3007WFP",
                "manu": "Dell, Inc.",
                "includes": "USB cable",
                "weight": 401.6,
                "price": 2199,
                "popularity": 6,
                "inStock": true,
                "store": "43.17614,-90.57341",
                "cat": [
                    "electronics",
                    "monitor"
                ],
                "features": [
                    "30\" TFT active matrix LCD, 2560 x 1600, .25mm dot pitch, 700:1 contrast"
                ]
            }
        ]
    }
}
Nice! A quick verification with monitor.xml should confirm that all is in order.
Note that the previous search query used the special *:* syntax to retrieve all documents.
Let's now add all the XML documents, and do some real searching.
./post.sh *.xml
Here's a demonstration of retrieving the name and id of all documents with inStock = falsehttp://localhost:8983/solr/select?q=inStock:false&wt=json&fl=id,name
{
    "responseHeader": {
        "status": 0,
        "QTime": 2,
        "params": {
            "wt": "json",
            "q": "inStock:false",
            "fl": "id,name"
        }
    },
    "response": {
        "numFound": 4,
        "start": 0,
        "docs": [
            {
                "id": "F8V7067-APL-KIT",
                "name": "Belkin Mobile Power Cord for iPod w/ Dock"
            },
            {
                "id": "IW-02",
                "name": "iPod & iPod Mini USB 2.0 Cable"
            },
            {
                "id": "EN7800GTX/2DHTV/256M",
                "name": "ASUS Extreme N7800GTX/2DHTV (256 MB)"
            },
            {
                "id": "100-435805",
                "name": "ATI Radeon X1900 XTX 512 MB PCIE Video Card"
            }
        ]
    }
}
You'll learn more about the various URL query parameters in a separate tutorial.

Shutdown

To shutdown Solr, from the terminal where you launched Solr, hit Ctrl+C. This will shutdown Solr cleanly.
Solr is fairly robust, so even in situations of OS or disk crashes, it is unlikely that Solr's index will become corrupted.

Using CURL as WGET Replacement in MAC

I was trying to download file in my MAC using "wget" but I found that "wget" is not available in MAC by default. After searching for few min I found a easy solution. CURL can be used to accomplish the same task. 

CURL Command is 
"curl -O http://apache.spinellicreations.com/lucene/solr/3.6.2/apache-solr-3.6.2.tgz"

To create an alias called `wget` that will simply run the command curl -O I ran the following command in my MAC terminal.


echo 'alias wget="curl -O"' >> ~/.bash_profile

Now when I run "wget",  it is actually executing curl -O to download the file.

"wget http://apache.spinellicreations.com/lucene/solr/3.6.2/apache-solr-3.6.2.tgz"

Hope this article is helpful for you...