Saturday, November 26, 2011

What Is Facebook Photo Fetcher?

Facebook Photo Fetcher is a Wordpress plugin that allows you to quickly and easily generate Wordpress photo galleries from any Facebook album you can access.

The idea was inspired by Fotobook, though its approach is fundamentally different: while Fotobook's emphasis is on automation, this plugin allows a great deal more customization. With it you can create galleries in any Post or Page you like, right alongside your regular content. You do this simply by putting a "magic HTML tag" in the post's content - much like Wordpress Shortcode. Upon saving, the tag will automatically be populated with the Facebook album content. Presentation is fully customizable via parameters to the "magic tag" - you can choose to show only a subset of an album's photos, change the number of photos per column, show photo captions, and more.

Also, Facebook Photo Fetcher does not limit you to just your own Facebook albums: you can create galleries from any album you can access, including groups and fanpages. This is very handy if you're not the main photo-poster in your social circle: just let your friend or family upload all those wedding pics, then import them directly to your blog!

Features:
  • Uses Facebook's API to instantly create Wordpress photo galleries from Facebook albums.
  • Galleries are fully customizable: you can import complete albums, select excerpts, random excerpts, album descriptions, photo captions, and more.
  • Galleries can be organized however you like: in any post or page, alone or alongside your other content.
  • Simple PHP template function allows programmers to manually embed albums in any template or widget.
  • Galleries can be created from any album you can access: yours, friends', groups', or fanpages'.
  • Built-in support for automatically attaching Post Thumbnails to any post or page that includes a gallery.
  • Built-in lightbox: Photos appear in attractive pop-up overlays without the need for any other plugins.
  • Admin panel handles all setup for you: Just click Connect, login, and you're ready to start making albums.
  • Admin panel includes utility to search for all albums you can access (and use to create galleries).
  • Admin panel includes utility to auto-traverse your galleries, updating those that've changed on Facebook.
  • No custom database modifications: all it does is automate the creation of post/page content for you.
To get started, check out the Instructions section below.


Demo


The following box contains a sample gallery imported from Facebook using this plugin. It's generated by one single "HTML magic tag" placed in the content of this page:

From Petrified Petra, posted by PederY on 6/13/2009 (Showing 16 of 60 items)

"Justin and I returned to the hotel after our late night at Petra. We decided to start bright and early the next day and get moving before the sun came up. Ladden with water, cameras and kebabs we ventured into one of the most amazing ancient cities on earth. And it would truly be a day to remember."

Generated by Facebook Photo Fetcher


Instructions


  1. Download the latest version from here, unzip it, and upload the extracted files to your plugins directory.
  2. Activate the plugin via your Wordpress admin panel.
  3. Head over to Settings -> FB Photo Fetcher.
  4. Click the "Login to Facebook" button to popup a Facebook login page. Enter your information, click "Login", then close the popup. Next, click "Grant Photo Permissions." Accept the permissions in the popup and when it says "Success," close it. Finally, click "Save Facebook Session." It should now say This plugin is successfully connected with xxxxxxx's Facebook account.
  5. Now we need to get the ID of an album you'd like to import. Click the "Search for Albums" button; It will automatically connect to Facebook and produce a list of all the albums you can access, each with an associated ID number. Let's use the example 1234567890123456789.
  6. Create a new post or page and enter the following tags, replacing the example ID with the one you'd like import. Note that you must use the HTML Editor (not Visual Editor) for the tags to be recognized:
    <!--FBGallery 1234567890123456789 --><!--/FBGallery-->
  7. Click "Save", and you're done! You can now view your new album.
Ways to customize the album's behavior (including Group and Fanpage support) are listed in the next section.


Customizing


Magic Tag Parameters


Let's start off with the basic code for importing a Facebook album into a page or post:
<!--FBGallery 1234567890123456789 --><!--/FBGallery-->

If you want a bit more control over how this presents the album, there are a number of parameters you can add to the opening tag, after the album ID number. These are:
  • cols=#: Set the number of photos to show per row (default is 4).
  • start=#: Start showing photos from the given index (i.e. to skip the first 2 photos, enter start=3)
  • max=#: Limit the number of photos (i.e. to only show the first 5 photos in an album, enter max=5)
  • rand=#: Show a random selection of photos from the album. This is applied after start & max, so to show 5 random photos from the entire album, enter rand=5; to randomize the first 5 items in the album, enter start=0 max=5 rand=5 (first limit the photos to the first 5, then randomize them).
  • orderby=reverse: Flip the order of photos in the album (i.e. to show only the latest, you'd use "orderby=reverse max=1")
  • hideHead=1: By default, albums will display their author, item count, and description prior to the first photo. Setting this will omit it that information.
  • swapHead=1: Swap the order of the information in the header - author first, description second.
  • hideCaps=1: By default, each photo shows an excerpt of its caption below it. Set this to omit them.
  • noLB=1: By default, this plugin outputs the JS needed to setup the lightbox popups. Set this to omit it.
As an example, the demo gallery above was created with the following tag:
<!--FBGallery 1234567890123456789 cols=4 max=16 swapHead=1 --><!--/FBGallery-->

Groups & Fanpages


Thus far, we've only discussed importing personal photo albums. If you'd like to import photos from a group or fanpage, you'll need to include one more parameter with the magic tag:
  • To show photos from a GROUP, add the parameter isGroup=1 and replace the albumID with a groupID.
  • To show photos from a FAN PAGE, add the parameter isPage=1 and replace the albumID with the pageID. At the moment you can't specify individual albums within fanpages; it will just pull all photos from all albums on the page. You can then limit what's shown by using the "start" and "max" parameters described above.
For example, if you wanted to create a gallery that randomly selects 10 photos from my fanpage, you'd use:
<!--FBGallery 10150100736095176 isPage=1 rand=10 --><!--/FBGallery-->

Albums from PHP


If you've got a custom template or widget in which you'd like to include a gallery, you can call the function fpf_fetch_album_content() directly. It accepts the same parameters as the HTML tags above; for example:
$album = fpf_fetch_album_content( '123456789', array('cols'=>6, 'max'=>18) );
echo $album['content'];
echo "Thumbnail: " . $album['thumb'] . ", Photo Count: " . $album['count'];

Post Thumbnails


This plugin supports automatic Wordpress Post Thumbnails. If you download and install the Add From Server plugin and set a thumbnail path in this plugin's Settings page, it will copy each album's thumbnail to your local server and attach it whenever you create or update a gallery.

Item Counts


Whenever a Facebook album is inserted into a post, that post will be given the postmeta "_fb_album_size", containing the number of shown items in the album. You can reference this from your code if you wish.

Wednesday, November 23, 2011

Backup and Restore MySQL Database Using mysqldump

mysqldump is an effective tool to backup MySQL database. It creates a *.sql file withDROP table, CREATE table and INSERT intosql-statements of the source database. To restore the database,  execute the *.sql file on destination database.  For MyISAM, usemysqlhotcopy method that we explained earlier, as it is faster for MyISAM tables.

Using mysqldump, you can backup a local database and restore it on a remote database at the same time, using a single command. In this article, let us review several practical examples on how to use mysqldump to backup and restore.

For the impatient, here is the quick snippet of how backup and restore MySQL database using mysqldump:
backup: # mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql

restore:# mysql -u root -p[root_password] [database_name] < dumpfilename.sql

How To Backup MySQL database

1. Backup a single database:

This example takes a backup of sugarcrm database and dumps the output to sugarcrm.sql
# mysqldump -u root -ptmppassword sugarcrm > sugarcrm.sql

# mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql
The sugarcrm.sql will contain drop table, create table and insert command for all the tables in the sugarcrm database. Following is a partial output of sugarcrm.sql, showing the dump information of accounts_contacts table:
--
-- Table structure for table `accounts_contacts`
--

DROP TABLE IF EXISTS `accounts_contacts`;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `accounts_contacts` (
`id` varchar(36) NOT NULL,
`contact_id` varchar(36) default NULL,
`account_id` varchar(36) default NULL,
`date_modified` datetime default NULL,
`deleted` tinyint(1) NOT NULL default '0',
PRIMARY KEY  (`id`),
KEY `idx_account_contact` (`account_id`,`contact_id`),
KEY `idx_contid_del_accid` (`contact_id`,`deleted`,`account_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
SET character_set_client = @saved_cs_client;

--
-- Dumping data for table `accounts_contacts`
--

LOCK TABLES `accounts_contacts` WRITE;
/*!40000 ALTER TABLE `accounts_contacts` DISABLE KEYS */;
INSERT INTO `accounts_contacts` VALUES ('6ff90374-26d1-5fd8-b844-4873b2e42091',
'11ba0239-c7cf-e87e-e266-4873b218a3f9','503a06a8-0650-6fdd-22ae-4873b245ae53',
'2008-07-23 05:24:30',1),
('83126e77-eeda-f335-dc1b-4873bc805541','7c525b1c-8a11-d803-94a5-4873bc4ff7d2',
'80a6add6-81ed-0266-6db5-4873bc54bfb5','2008-07-23 05:24:30',1),
('4e800b97-c09f-7896-d3d7-48751d81d5ee','f241c222-b91a-d7a9-f355-48751d6bc0f9',
'27060688-1f44-9f10-bdc4-48751db40009','2008-07-23 05:24:30',1),
('c94917ea-3664-8430-e003-487be0817f41','c564b7f3-2923-30b5-4861-487be0f70cb3',
'c71eff65-b76b-cbb0-d31a-487be06e4e0b','2008-07-23 05:24:30',1),
('7dab11e1-64d3-ea6a-c62c-487ce17e4e41','79d6f6e5-50e5-9b2b-034b-487ce1dae5af',
'7b886f23-571b-595b-19dd-487ce1eee867','2008-07-23 05:24:30',1);
/*!40000 ALTER TABLE `accounts_contacts` ENABLE KEYS */;
UNLOCK TABLES;

2. Backup multiple databases:

If you want to backup multiple databases, first identify the databases that you want to backup using the show databases as shown below:
# mysql -u root -ptmppassword

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| bugs               |
| mysql              |
| sugarcr            |
+--------------------+
4 rows in set (0.00 sec)
For example, if you want to take backup of both sugarcrm and bugs database, execute the mysqldump as shown below:
# mysqldump -u root -ptmppassword --databases bugs sugarcrm > bugs_sugarcrm.sql
Verify the bugs_sugarcrm.sql dumpfile contains both the database backup.
# grep -i "Current database:" /tmp/bugs_sugarcrm.sql
-- Current Database: `mysql`
-- Current Database: `sugarcrm`

3. Backup all the databases:

The following example takes a backup of  all the database of the MySQL instance.
# mysqldump -u root -ptmppassword --all-databases > /tmp/all-database.sql

4. Backup a specific table:

In this example, we backup only the accounts_contacts table from sugarcrm database.
# mysqldump -u root -ptmppassword sugarcrm accounts_contacts \
      > /tmp/sugarcrm_accounts_contacts.sql

4. Different mysqldump group options:

  • –opt is a group option, which is same as –add-drop-table, –add-locks, –create-options, –quick, –extended-insert, –lock-tables, –set-charset, and –disable-keys. opt is enabled by default, disable with –skip-opt.
  • –compact is a group option, which gives less verbose output (useful for debugging). Disables structure comments and header/footer constructs. Enables options –skip-add-drop-table –no-set-names –skip-disable-keys –skip-add-locks

How To Restore MySQL database

1. Restore a database

In this example, to restore the sugarcrm database, execute mysql with < as shown below. When you are restoring the dumpfilename.sql on a remote database, make sure to create the sugarcrm database before you can perform the restore.
# mysql -u root -ptmppassword

mysql> create database sugarcrm;
Query OK, 1 row affected (0.02 sec)

# mysql -u root -ptmppassword sugarcrm < /tmp/sugarcrm.sql

# mysql -u root -p[root_password] [database_name] < dumpfilename.sql

2. Backup a local database and restore to remote server using single command:

This is a sleek option, if you want to keep a read-only database on the remote-server, which is a copy of the master database on local-server. The example below will backup the sugarcrm database on the local-server and restore it as sugarcrm1 database on the remote-server. Please note that you should first create the sugarcrm1 database on the remote-server before executing the following command.
[local-server]# mysqldump -u root -ptmppassword sugarcrm | mysql \
                 -u root -ptmppassword --host=remote-server -C sugarcrm1
[Note: There are two -- (hyphen) in front of host]

Monday, November 21, 2011

How to share your USB connected scanner on your network

Tips for scanning in Mac OS X v10.6
  • Check the list of supported scanners in Mac OS X v10.6 for the model of scanner you are about to connect to your Mac.
  • Use Software Update to automatically install third-party scanner / printer software updates.
  • Connect a USB scanner to automatically create the scanner / print queue.
  • You can share your USB connected scanner with other Macs on your home network.
  • You can scan from various applications:
    • Image Capture
    • Preview
    • Print & Fax preferences in System Preferences
    • Scanner / Printer queue
    • Some third-party applications
Important: If your scanner driver does support control panel functions in Mac OS X, pressing a scan button on your device may not begin the scanning process. Simply use one of the above applications to control the scanner.
See below for more details about these features.
 
Before you connect your scanner
  • Run Software Update to check for the latest third-party printer / scanner software and updates.
  • Make sure the scanner is powered on and doesn't have any alerts displayed in its control panel.
  • Make sure you know an administrator account name and password for your Mac.
     
How to connect to a scanner
Simply connect your scanner via a USB cable. A scanner / printer queue will be created for it in Mac OS X.
Note: Refrain from installing the software that came with your scanner as it may be out of date. Mac OS X v10.6 andSoftware Update contain the most recent versions of scanner software. You will see future updates when they are made available via Software Update.
 
How to scan
Note: This article discusses scanning via the Image Capture application (located in the Applications folder). Scanning with other applications such as Preview is a very similar process.
Simplified scan mode
In the "simplified" scanner interface, follow these steps:
  1. Place the item(s) you would like to scan on the scanner bed.
  2. Open Image Capture (located in the Applications folder).

    Image Capture window 
  3. If your scanner supports different modes, you will see a "Mode:" pop-up menu in Image Capture. Modes may include Flatbed, Transparency Positive, Transparency Negative, and more.
  4. Check (enable) "Detect Separate Items" to have scanned objects automatically selected and straightened. Tip:Objects with high contrast edging will increase the accuracy of auto-selection.
  5. Select the "Scan To:" destination:
    • A folder of your choosing. A number of folders are already pre-configured or choose "Other…" to select the folder you want.
    • An application such as iPhoto, Aperture or Preview.
    • Mail application, to have each of your scanned images put into its own email message.
  6. Click "Scan" to scan.
Note: The scanned items will become JPEG images with 300 dpi and incrementally named scan1.jpeg, scan2.jpeg, and so forth.
Selecting areas to scan
If you want to select specific areas to scan (or if you unchecked "Detect Separate Items"), follow these steps:
  1. Deselect all currently selected scan areas by clicking in an empty area that is not yet selected (selected areas are outlined by a border that has a line of dashes).
  2. To specify the scanning area, click and drag to cover the area you want to scan.
  3. To resize a selection area, click within the border of the selected area.  Gray dots appear on the border.  When your cursor hovers over a handle it will turn red. Click and drag the red handle to resize the scan area. Tip: You can Shift-click another area to select more than one.
  4. If you want to delete the selection, press Delete.
  5. If you want to rotate the selection, click the rotation handle just at the end of the line that starts in the center of the selection. When your cursor is near this handle, it turns red and a transparent image of a person will appear within the area. Click the red handle and adjust the rotation to your liking. Note: There could be a border handle to resize your selection near this handle; make sure you click on the correct handle.


  6. To create a new selection area, simply click and drag in an area that is not part of a selection.

  1. From the Apple () menu, choose System Preferences.
  2. From the View menu, choose Sharing.
  3. Enable (check) "Scanner Sharing".
  4. Select the connected scanner that you would like to share.
How to connect to a network shared scanner
Image Capture and Printer / Scanner queue
  1. Open Image Capture or Printer / Scanner queue.
  2. Select the Scanner from the "SHARED" group in the left pane.
Preview and other applications
  1. Open Preview from your Dock or the Applications folder.
  2. First enable Networked devices. Choose File > Import from Scanner > Include Networked Devices.
  3. Select your scanner. Choose File > Import from Scanner > (your scanner under "Network Devices").

Friday, November 11, 2011

Shell Script To Backup MySql Database Server

#!/bin/bash
# Shell script to backup MySql database
# To backup Nysql databases file to /backup dir and later pick up by your
# script. You can skip few databases from backup too.
# For more info please see (Installation info):
# http://www.cyberciti.biz/nixcraft/vivek/blogger/2005/01/mysql-backup-script.html
# Last updated: Aug - 2005
# --------------------------------------------------------------------
# This is a free shell script under GNU GPL version 2.0 or above
# Copyright (C) 2004, 2005 nixCraft project
# Feedback/comment/suggestions : http://cyberciti.biz/fb/
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# -------------------------------------------------------------------------
 
MyUSER="SET-MYSQL-USER-NAME"     # USERNAME
MyPASS="SET-PASSWORD"       # PASSWORD
MyHOST="localhost"          # Hostname
 
# Linux bin paths, change this if it can not be autodetected via which command
MYSQL="$(which mysql)"
MYSQLDUMP="$(which mysqldump)"
CHOWN="$(which chown)"
CHMOD="$(which chmod)"
GZIP="$(which gzip)"
 
# Backup Dest directory, change this if you have someother location
DEST="/backup"
 
# Main directory where backup will be stored
MBD="$DEST/mysql"
 
# Get hostname
HOST="$(hostname)"
 
# Get data in dd-mm-yyyy format
NOW="$(date +"%d-%m-%Y")"
 
# File to store current backup file
FILE=""
# Store list of databases
DBS=""
 
# DO NOT BACKUP these databases
IGGY="test"
 
[ ! -d $MBD ] && mkdir -p $MBD || :
 
# Only root can access it!
$CHOWN 0.0 -R $DEST
$CHMOD 0600 $DEST
 
# Get all database list first
DBS="$($MYSQL -u $MyUSER -h $MyHOST -p$MyPASS -Bse 'show databases')"
 
for db in $DBS
do
    skipdb=-1
    if [ "$IGGY" != "" ];
    then
 for i in $IGGY
 do
     [ "$db" == "$i" ] && skipdb=1 || :
 done
    fi
 
    if [ "$skipdb" == "-1" ] ; then
 FILE="$MBD/$db.$HOST.$NOW.gz"
 # do all inone job in pipe,
 # connect to mysql using mysqldump for select mysql database
 # and pipe it out to gz file in backup dir :)
        $MYSQLDUMP -u $MyUSER -h $MyHOST -p$MyPASS $db | $GZIP -9 > $FILE
    fi
done
http://bash.cyberciti.biz/backup/backup-mysql-database-server-2/