Pages

Monday, September 15, 2014

Xilisoft Video Cutter v2.2.0 + License Key

F6D3-A1A1-8F5C-6C35-D021-B10C-BC19-3506

4D78-1A1A-35E7-E783-1750-DD82-A427-8682

B187-E4E5-3A18-1874-0CC6-5DD5-ED13-8B50

83AD-7E4E-1835-3ACA-894E-651C-1C03-B560

35F1-BD7C-6824-E0A5-EAFC-4C18-FA7C-5026

A381-F4E4-DA39-3860-B684-8F93-156F-8BBF

Wednesday, September 3, 2014

HBase Shell Comments

HBase shell commands

As told in HBase introduction, HBase provides Extensible jruby-based (JIRB) shell as a feature to execute some commands(each command represents one functionality).
HBase shell commands are mainly categorized into 6 parts
1) General  HBase shell commands
status Show cluster status. Can be ‘summary’, ‘simple’, or ‘detailed’. The
default is ‘summary’. hbase> status
hbase> status ‘simple’
hbase> status ‘summary’
hbase> status ‘detailed’
version Output this HBase versionUsage: hbase> version
whoami Show the current hbase user.Usage: hbase> whoami
2) Tables Management commands
alter Alter column family schema; pass table name and a dictionary
specifying new column family schema. Dictionaries are described
on the main help command output. Dictionary must include name
of column family to alter.For example, to change or add the ‘f1′ column family in table ‘t1′ from
current value to keep a maximum of 5 cell VERSIONS, do: hbase> alter ‘t1′, NAME => ‘f1′, VERSIONS => 5
You can operate on several column families:
hbase> alter ‘t1′, ‘f1′, {NAME => ‘f2′, IN_MEMORY => true}, {NAME => ‘f3′, VERSIONS => 5}
To delete the ‘f1′ column family in table ‘t1′, use one of:hbase> alter ‘t1′, NAME => ‘f1′, METHOD => ‘delete’
hbase> alter ‘t1′, ‘delete’ => ‘f1′
You can also change table-scope attributes like MAX_FILESIZE, READONLY,
MEMSTORE_FLUSHSIZE, DEFERRED_LOG_FLUSH, etc. These can be put at the end;
for example, to change the max size of a region to 128MB, do:
hbase> alter ‘t1′, MAX_FILESIZE => ‘134217728’
You can add a table coprocessor by setting a table coprocessor attribute:
hbase> alter ‘t1′,
‘coprocessor’=>’hdfs:///foo.jar|com.foo.FooRegionObserver|1001|arg1=1,arg2=2
Since you can have multiple coprocessors configured for a table, a
sequence number will be automatically appended to the attribute name
to uniquely identify it.
The coprocessor attribute must match the pattern below in order for
the framework to understand how to load the coprocessor classes:
[coprocessor jar file location] | class name | [priority] | [arguments]
You can also set configuration settings specific to this table or column family:
hbase> alter ‘t1′, CONFIGURATION => {‘hbase.hregion.scan.loadColumnFamiliesOnDemand’ => ‘true’}
hbase> alter ‘t1′, {NAME => ‘f2′, CONFIGURATION => {‘hbase.hstore.blockingStoreFiles’ => ’10’}}
You can also remove a table-scope attribute:
hbase> alter ‘t1′, METHOD => ‘table_att_unset’, NAME => ‘MAX_FILESIZE’
hbase> alter ‘t1′, METHOD => ‘table_att_unset’, NAME => ‘coprocessor$1′
There could be more than one alteration in one command:
hbase> alter ‘t1′, { NAME => ‘f1′, VERSIONS => 3 },
{ MAX_FILESIZE => ‘134217728’ }, { METHOD => ‘delete’, NAME => ‘f2′ },
OWNER => ‘johndoe’, METADATA => { ‘mykey’ => ‘myvalue’ }
create Create table; pass table name, a dictionary of specifications per
column family, and optionally a dictionary of table configuration. hbase> create ‘t1′, {NAME => ‘f1′, VERSIONS => 5}
hbase> create ‘t1′, {NAME => ‘f1′}, {NAME => ‘f2′}, {NAME => ‘f3′}
hbase> # The above in shorthand would be the following:
hbase> create ‘t1′, ‘f1′, ‘f2′, ‘f3′
hbase> create ‘t1′, {NAME => ‘f1′, VERSIONS => 1, TTL => 2592000, BLOCKCACHE => true}
hbase> create ‘t1′, {NAME => ‘f1′, CONFIGURATION => {‘hbase.hstore.blockingStoreFiles’ => ’10’}}
Table configuration options can be put at the end.
describe Describe the named table. hbase> describe ‘t1′
disable Start disable of named table hbase> disable ‘t1′
disable_all Disable all of tables matching the given regex hbase> disable_all ‘t.*’
is_disabled verifies Is named table disabled hbase> is_disabled ‘t1′
drop  Drop the named table. Table must first be disabled hbase> drop ‘t1′
drop_all Drop all of the tables matching the given regex hbase> drop_all ‘t.*’
enable Start enable of named table hbase> enable ‘t1′
enable_all Enable all of the tables matching the given regex hbase> enable_all ‘t.*’
is_enabled verifies Is named table enabled hbase> is_enabled ‘t1′
exists Does the named table exist hbase> exists ‘t1′
list List all tables in hbase. Optional regular expression parameter could
be used to filter the output hbase> list
hbase> list ‘abc.*’
show_filters Show all the filters in hbase. hbase> show_filters
alter_status Get the status of the alter command. Indicates the number of regions of the table that have received the updated schema Pass table name. hbase> alter_status ‘t1′
alter_async Alter column family schema, does not wait for all regions to receive the
schema changes. Pass table name and a dictionary specifying new column
family schema. Dictionaries are described on the main help command output.
Dictionary must include name of column family to alter. To change or add the ‘f1′ column family in table ‘t1′ from defaults
to instead keep a maximum of 5 cell VERSIONS, do:hbase> alter_async ‘t1′, NAME => ‘f1′, VERSIONS => 5To delete the ‘f1′ column family in table ‘t1′, do:
hbase> alter_async ‘t1′, NAME => ‘f1′, METHOD => ‘delete’or a shorter version:hbase> alter_async ‘t1′, ‘delete’ => ‘f1′
You can also change table-scope attributes like MAX_FILESIZE
MEMSTORE_FLUSHSIZE, READONLY, and DEFERRED_LOG_FLUSH.
For example, to change the max size of a family to 128MB, do:
hbase> alter ‘t1′, METHOD => ‘table_att’, MAX_FILESIZE => ‘134217728’
There could be more than one alteration in one command:
hbase> alter ‘t1′, {NAME => ‘f1′}, {NAME => ‘f2′, METHOD => ‘delete’}
To check if all the regions have been updated, use alter_status <table_name>
3) Data Manipulation commands  
count Count the number of rows in a table. Return value is the number of rows.
This operation may take a LONG time (Run ‘$HADOOP_HOME/bin/hadoop jar
hbase.jar rowcount’ to run a counting mapreduce job). Current count is shown
every 1000 rows by default. Count interval may be optionally specified. Scan
caching is enabled on count scans by default. Default cache size is 10 rows.
If your rows are small in size, you may want to increase this
parameter. Examples:hbase> count ‘t1′
hbase> count ‘t1′, INTERVAL => 100000
hbase> count ‘t1′, CACHE => 1000
hbase> count ‘t1′, INTERVAL => 10, CACHE => 1000 The same commands also can be run on a table reference. Suppose you had a reference
t to table ‘t1′, the corresponding commands would be:hbase> t.count
hbase> t.count INTERVAL => 100000
hbase> t.count CACHE => 1000
hbase> t.count INTERVAL => 10, CACHE => 1000
delete Put a delete cell value at specified table/row/column and optionally
timestamp coordinates. Deletes must match the deleted cell’s
coordinates exactly. When scanning, a delete cell suppresses older
versions. To delete a cell from ‘t1′ at row ‘r1′ under column ‘c1′
marked with the time ‘ts1′, do: hbase> delete ‘t1′, ‘r1′, ‘c1′, ts1
The same command can also be run on a table reference. Suppose you had a reference
t to table ‘t1′, the corresponding command would be:hbase> t.delete ‘r1′, ‘c1′, ts1
deleteall Delete all cells in a given row; pass a table name, row, and optionally
a column and timestamp. Examples:hbase> deleteall ‘t1′, ‘r1′
hbase> deleteall ‘t1′, ‘r1′, ‘c1′
hbase> deleteall ‘t1′, ‘r1′, ‘c1′, ts1 The same commands also can be run on a table reference. Suppose you had a reference
t to table ‘t1′, the corresponding command would be:hbase> t.deleteall ‘r1′
hbase> t.deleteall ‘r1′, ‘c1′
hbase> t.deleteall ‘r1′, ‘c1′, ts1
get Get row or cell contents; pass table name, row, and optionally
a dictionary of column(s), timestamp, timerange and versions. Examples: hbase> get ‘t1′, ‘r1′
hbase> get ‘t1′, ‘r1′, {TIMERANGE => [ts1, ts2]}
hbase> get ‘t1′, ‘r1′, {COLUMN => ‘c1′}
hbase> get ‘t1′, ‘r1′, {COLUMN => ['c1', 'c2', 'c3']}
hbase> get ‘t1′, ‘r1′, {COLUMN => ‘c1′, TIMESTAMP => ts1}
hbase> get ‘t1′, ‘r1′, {COLUMN => ‘c1′, TIMERANGE => [ts1, ts2], VERSIONS => 4}
hbase> get ‘t1′, ‘r1′, {COLUMN => ‘c1′, TIMESTAMP => ts1, VERSIONS => 4}
hbase> get ‘t1′, ‘r1′, {FILTER => “ValueFilter(=, ‘binary:abc’)”}
hbase> get ‘t1′, ‘r1′, ‘c1′
hbase> get ‘t1′, ‘r1′, ‘c1′, ‘c2′
hbase> get ‘t1′, ‘r1′, ['c1', 'c2']
Besides the default ‘toStringBinary’ format, ‘get’ also supports custom formatting by
column. A user can define a FORMATTER by adding it to the column name in the get
specification. The FORMATTER can be stipulated:1. either as a org.apache.hadoop.hbase.util.Bytes method name (e.g, toInt, toString)
2. or as a custom class followed by method name: e.g. ‘c(MyFormatterClass).format’.Example formatting cf:qualifier1 and cf:qualifier2 both as Integers:
hbase> get ‘t1′, ‘r1′ {COLUMN => ['cf:qualifier1:toInt',
'cf:qualifier2:c(org.apache.hadoop.hbase.util.Bytes).toInt'] }
Note that you can specify a FORMATTER by column only (cf:qualifer). You cannot specify
a FORMATTER for all columns of a column family.The same commands also can be run on a reference to a table (obtained via get_table or
create_table). Suppose you had a reference t to table ‘t1′, the corresponding commands
would be:
hbase> t.get ‘r1′
hbase> t.get ‘r1′, {TIMERANGE => [ts1, ts2]}
hbase> t.get ‘r1′, {COLUMN => ‘c1′}
hbase> t.get ‘r1′, {COLUMN => ['c1', 'c2', 'c3']}
hbase> t.get ‘r1′, {COLUMN => ‘c1′, TIMESTAMP => ts1}
hbase> t.get ‘r1′, {COLUMN => ‘c1′, TIMERANGE => [ts1, ts2], VERSIONS => 4}
hbase> t.get ‘r1′, {COLUMN => ‘c1′, TIMESTAMP => ts1, VERSIONS => 4}
hbase> t.get ‘r1′, {FILTER => “ValueFilter(=, ‘binary:abc’)”}
hbase> t.get ‘r1′, ‘c1′
hbase> t.get ‘r1′, ‘c1′, ‘c2′
hbase> t.get ‘r1′, ['c1', 'c2']
get_counter Return a counter cell value at specified table/row/column coordinates.
A cell cell should be managed with atomic increment function oh HBase
and the data should be binary encoded. Example: hbase> get_counter ‘t1′, ‘r1′, ‘c1′
The same commands also can be run on a table reference. Suppose you had a reference
t to table ‘t1′, the corresponding command would be:
hbase> t.get_counter ‘r1′, ‘c1′
incr Increments a cell ‘value’ at specified table/row/column coordinates.
To increment a cell value in table ‘t1′ at row ‘r1′ under column
‘c1′ by 1 (can be omitted) or 10 do: hbase> incr ‘t1′, ‘r1′, ‘c1′
hbase> incr ‘t1′, ‘r1′, ‘c1′, 1
hbase> incr ‘t1′, ‘r1′, ‘c1′, 10
The same commands also can be run on a table reference. Suppose you had a reference
t to table ‘t1′, the corresponding command would be:hbase> t.incr ‘r1′, ‘c1′
hbase> t.incr ‘r1′, ‘c1′, 1
hbase> t.incr ‘r1′, ‘c1′, 10
put Put a cell ‘value’ at specified table/row/column and optionally
timestamp coordinates. To put a cell value into table ‘t1′ at
row ‘r1′ under column ‘c1′ marked with the time ‘ts1′, do: hbase> put ‘t1′, ‘r1′, ‘c1′, ‘value’, ts1
The same commands also can be run on a table reference. Suppose you had a reference
t to table ‘t1′, the corresponding command would be:
hbase> t.put ‘r1′, ‘c1′, ‘value’, ts1
scan Scan a table; pass table name and optionally a dictionary of scanner
specifications. Scanner specifications may include one or more of:
TIMERANGE, FILTER, LIMIT, STARTROW, STOPROW, TIMESTAMP, MAXLENGTH,
or COLUMNS, CACHEIf no columns are specified, all columns will be scanned.
To scan all members of a column family, leave the qualifier empty as in
‘col_family:’.The filter can be specified in two ways:
1. Using a filterString – more information on this is available in the
Filter Language document attached to the HBASE-4176 JIRA
2. Using the entire package name of the filter.Some examples:hbase> scan ‘.META.’
hbase> scan ‘.META.’, {COLUMNS => ‘info:regioninfo’}
hbase> scan ‘t1′, {COLUMNS => ['c1', 'c2'], LIMIT => 10, STARTROW => ‘xyz’}
hbase> scan ‘t1′, {COLUMNS => ‘c1′, TIMERANGE => [1303668804, 1303668904]}
hbase> scan ‘t1′, {FILTER => “(PrefixFilter (‘row2′) AND
(QualifierFilter (>=, ‘binary:xyz’))) AND (TimestampsFilter ( 123, 456))”}
hbase> scan ‘t1′, {FILTER =>
org.apache.hadoop.hbase.filter.ColumnPaginationFilter.new(1, 0)} For experts, there is an additional option — CACHE_BLOCKS — which
switches block caching for the scanner on (true) or off (false). By
default it is enabled. Examples:hbase> scan ‘t1′, {COLUMNS => ['c1', 'c2'], CACHE_BLOCKS => false}
Also for experts, there is an advanced option — RAW — which instructs the
scanner to return all cells (including delete markers and uncollected deleted
cells). This option cannot be combined with requesting specific COLUMNS.
Disabled by default. Example:
hbase> scan ‘t1′, {RAW => true, VERSIONS => 10}
Besides the default ‘toStringBinary’ format, ‘scan’ supports custom formatting
by column. A user can define a FORMATTER by adding it to the column name in
the scan specification. The FORMATTER can be stipulated:
1. either as a org.apache.hadoop.hbase.util.Bytes method name (e.g, toInt, toString)
2. or as a custom class followed by method name: e.g. ‘c(MyFormatterClass).format’.
Example formatting cf:qualifier1 and cf:qualifier2 both as Integers:
hbase> scan ‘t1′, {COLUMNS => ['cf:qualifier1:toInt',
'cf:qualifier2:c(org.apache.hadoop.hbase.util.Bytes).toInt'] }
Note that you can specify a FORMATTER by column only (cf:qualifer). You cannot
specify a FORMATTER for all columns of a column family.
Scan can also be used directly from a table, by first getting a reference to a
table, like such:
hbase> t = get_table ‘t’
hbase> t.scan
Note in the above situation, you can still provide all the filtering, columns,
options, etc as described above.
truncate Disables, drops and recreates the specified table.
Examples:
hbase>truncate ‘t1′
4) HBase surgery tools
assign Assign a region. Use with caution. If region already assigned,
this command will do a force reassign. For experts only.
Examples:
hbase> assign ‘REGION_NAME’
balancer Trigger the cluster balancer. Returns true if balancer ran and was able to
tell the region servers to unassign all the regions to balance (the re-assignment itself is async).
Otherwise false (Will not run if regions in transition).
Examples:
hbase> balancer
balance_switch Enable/Disable balancer. Returns previous balancer state.
Examples: hbase> balance_switch true
hbase> balance_switch false
close_region Close a single region. Ask the master to close a region out on the cluster
or if ‘SERVER_NAME’ is supplied, ask the designated hosting regionserver to
close the region directly. Closing a region, the master expects ‘REGIONNAME’
to be a fully qualified region name. When asking the hosting regionserver to
directly close a region, you pass the regions’ encoded name only. A region
name looks like this:TestTable,0094429456,1289497600452.527db22f95c8a9e0116f0cc13c680396.The trailing period is part of the regionserver name. A region’s encoded name
is the hash at the end of a region name; e.g. 527db22f95c8a9e0116f0cc13c680396
(without the period). A ‘SERVER_NAME’ is its host, port plus startcode. For
example: host187.example.com,60020,1289493121758 (find servername in master ui
or when you do detailed status in shell). This command will end up running
close on the region hosting regionserver. The close is done without the
master’s involvement (It will not know of the close). Once closed, region will
stay closed. Use assign to reopen/reassign. Use unassign or move to assign
the region elsewhere on cluster. Use with caution. For experts only.
Examples:hbase> close_region ‘REGIONNAME’
hbase> close_region ‘REGIONNAME’, ‘SERVER_NAME’
compact Compact all regions in passed table or pass a region row
to compact an individual region. You can also compact a single column
family within a region.
Examples:
Compact all regions in a table:
hbase> compact ‘t1′
Compact an entire region:
hbase> compact ‘r1′
Compact only a column family within a region:
hbase> compact ‘r1′, ‘c1′
Compact a column family within a table:
hbase> compact ‘t1′, ‘c1′
flush Flush all regions in passed table or pass a region row to
flush an individual region. For example:hbase> flush ‘TABLENAME’
hbase> flush ‘REGIONNAME’
major_compact Run major compaction on passed table or pass a region row
to major compact an individual region. To compact a single
column family within a region specify the region name
followed by the column family name.
Examples:
Compact all regions in a table:
hbase> major_compact ‘t1′
Compact an entire region:
hbase> major_compact ‘r1′
Compact a single column family within a region:
hbase> major_compact ‘r1′, ‘c1′
Compact a single column family within a table:
hbase> major_compact ‘t1′, ‘c1′
move Move a region. Optionally specify target regionserver else we choose one
at random. NOTE: You pass the encoded region name, not the region name so
this command is a little different to the others. The encoded region name
is the hash suffix on region names: e.g. if the region name were
TestTable,0094429456,1289497600452.527db22f95c8a9e0116f0cc13c680396. then
the encoded region name portion is 527db22f95c8a9e0116f0cc13c680396
A server name is its host, port plus startcode. For example:
host187.example.com,60020,1289493121758
Examples:hbase> move ‘ENCODED_REGIONNAME’
hbase> move ‘ENCODED_REGIONNAME’, ‘SERVER_NAME’
split Split entire table or pass a region to split individual region. With the
second parameter, you can specify an explicit split key for the region.
Examples:
split ‘tableName’
split ‘regionName’ # format: ‘tableName,startKey,id’
split ‘tableName’, ‘splitKey’
split ‘regionName’, ‘splitKey’
unassign Unassign a region. Unassign will close region in current location and then
reopen it again. Pass ‘true’ to force the unassignment (‘force’ will clear
all in-memory state in master before the reassign. If results in
double assignment use hbck -fix to resolve. To be used by experts).
Use with caution. For expert use only. Examples:hbase> unassign ‘REGIONNAME’
hbase> unassign ‘REGIONNAME’, true
hlog_roll Roll the log writer. That is, start writing log messages to a new file.
The name of the regionserver should be given as the parameter. A
‘server_name’ is the host, port plus startcode of a regionserver. For
example: host187.example.com,60020,1289493121758 (find servername in
master ui or when you do detailed status in shell) hbase>hlog_roll
zk_dump Dump status of HBase cluster as seen by ZooKeeper. Example:
hbase>zk_dump

5) Cluster replication tools
add_peer Add a peer cluster to replicate to, the id must be a short and
the cluster key is composed like this:
hbase.zookeeper.quorum:hbase.zookeeper.property.clientPort:zookeeper.znode.parent
This gives a full path for HBase to connect to another cluster.
Examples:hbase> add_peer ‘1’, “server1.cie.com:2181:/hbase
hbase> add_peer ‘2’, “zk1,zk2,zk3:2182:/hbase-prod”
remove_peer Stops the specified replication stream and deletes all the meta
information kept about it. Examples: hbase> remove_peer ‘1’
list_peers List all replication peer clusters.
hbase> list_peers
enable_peer Restarts the replication to the specified peer cluster,
continuing from where it was disabled.Examples: hbase> enable_peer ‘1’
disable_peer Stops the replication stream to the specified cluster, but still
keeps track of new edits to replicate.Examples: hbase> disable_peer ‘1’
start_replication Restarts all the replication features. The state in which each
stream starts in is undetermined.
WARNING:
start/stop replication is only meant to be used in critical load situations.
Examples: hbase> start_replication
stop_replication Stops all the replication features. The state in which each
stream stops in is undetermined.
WARNING:
start/stop replication is only meant to be used in critical load situations.
Examples: hbase> stop_replication
6) Security tools
grant Grant users specific rights.
Syntax : grantpermissions is either zero or more letters from the set “RWXCA”.
READ(‘R’), WRITE(‘W’), EXEC(‘X’), CREATE(‘C’), ADMIN(‘A’)For example:hbase> grant ‘bobsmith’, ‘RWXCA’
hbase> grant ‘bobsmith’, ‘RW’, ‘t1′, ‘f1′, ‘col1′
revoke Revoke a user’s access rights.
Syntax : revoke
For example: hbase> revoke ‘bobsmith’, ‘t1′, ‘f1′, ‘col1′
user_permission Show all permissions for the particular user.
Syntax : user_permission
For example:hbase> user_permission
hbase> user_permission ‘table1′

Monday, November 25, 2013

IDM 7.1 Download manager Activated LifeTime [ no need of crack or patch ]


THE internet download Manager (IDM) is a very simple to use tool to increase download speeds by up to 500 % more then 5 time speed, resume and amd more control schedule downloads. per the opinions of IDM (Internet download Manager 6.01 activated )users web transfer Manager could be a good accelerator program to transfer your favorite code, games, cd, videodisc and mp3 music, movies, software and software system programs abundant faster! Just 3.38MB


Special Features Of This Edition 

* No need of crack 
* No need of patch
* Full Version, All option are available.
* Easy one to use.


Download Idm PreActive :

Download IDm 7.1 Pre-Actived [Mediafire]  

f7bdc530e02545589d2e6361f9d88fdb

Saturday, October 20, 2012

PHP - Classes And Inheritance


OOP stands for Object-Oriented Programming. It is a programming concept that caught on in the 1990's. OOP focuses on 'objects' which are, well, objects. They have certain characteristics, and can behave in certain ways. OOP programming has a few concepts that define it. One of the defining features we will start with is called a class.

A class shows what an object has and can do, and it consists of members. Members can be divided into properties and methods. Properties are the characteristics of the object. For example, cheese (object) has the properties of type (maybe Gorgonzola, or cheddar), color (green, or white), and flavor (awful or delicious). Methods are the actions and behaviors the object can do. For example, cheese (object) can mold. Now let's see the technical side of it.

class Cheese { // A class, shows what all cheese has
var $type; // These are a class's attributes, or properties
var $flavor; // They are sometimes called characteristics, too.
var $color; // All cheeses have these 3 properties

// These functions are called 'methods'
// It's what the cheese can do for you
// and what you can do for your cheese
function giveDetails ($thetype, $theflavor, $thecolor) {
$this->type = $thetype;
$this->flavor = $theflavor;
$this->color = $thecolor;
}

function showType() {
return $this->type;
}
function showColor() {
return $this->color;
}
function showFlavor() {
return $this->flavor;
}
}

You declare a class by using the word 'class'. It's common to define the properties first. You define properties by using 'var'. Next the methods are defined. When using any of the properties in your methods, you use the $this keyword. If I want to use the "flavor" property in a function, I would put $this->flavor.

Now let's see this class in action.

<?php

class Cheese { // A class, shows what all cheese has
var $type; // These are a class's attributes, or properties
var $flavor; // They are sometimes called characteristics, too.
var $color; // All cheeses have these 3 properties

// These functions are called 'methods'
// It's what the cheese can do for you
// and what you can do for your cheese
function giveDetails ($thetype, $theflavor, $thecolor) {
$this->type = $thetype;
$this->flavor = $theflavor;
$this->color = $thecolor;
}

function showType() {
return $this->type;
}
function showColor() {
return $this->color;
}
function showFlavor() {
return $this->flavor;
}
}

$zargento = new Cheese; // Zargento is a brand of cheese

// We will now give it characteristics
$zargento->giveDetails("Gorgonzola", "Awful", "Green and white");

// Now let's see those details
echo $zargento->showType();
echo "<br>"; // It seems DIC likes to get rid of my HTML br tags
echo $zargento->showFlavor();
echo "<br>";
echo $zargento->showColor();

?>


You declare a class by using the word 'class'. It's common to define the properties first. You define properties by using 'var'. Next the methods are defined. When using any of the properties in your methods, you use the $this keyword. If I want to use the "flavor" property in a function, I would put $this->flavor.

Now let's see this class in action.

You make a new object by using 'new'. $zargento is now a Cheese object. It has access to all the properties and methods we outlined in the class. If we want $zargento to use the giveDetails() function, you use '$zargento->giveDetails()' as was used above. If you run the above script, the output will be:


Gorgonzola
Awful
Green and white

Now that you've gotten a good idea of how classes work, we can move one step further with another concept of OOP called inheritance. This allows you to create new classes using already created classes. Here is an example:


class MoreCheese extends Cheese {
var $cost;

function giveCost($f) {
$this->cost = $f;
}

function showCost() {
return $this->cost;
}
}

You use 'extends' to grab the methods and properties from the Cheese class and add them to the MoreCheese class. Let's see the full code.

<?php

class Cheese { // A class, shows what all cheese has
var $type; // These are a class's attributes, or properties
var $flavor; // They are sometimes called characteristics, too.
var $color; // All cheeses have these 3 properties

// These functions are called 'methods'
// It's what the cheese can do for you
// and what you can do for your cheese
function giveDetails ($thetype, $theflavor, $thecolor) {
$this->type = $thetype;
$this->flavor = $theflavor;
$this->color = $thecolor;
}

function showType() {
return $this->type;
}
function showColor() {
return $this->color;
}
function showFlavor() {
return $this->flavor;
}
}

class MoreCheese extends Cheese {
var $cost;

function giveCost($f) {
$this->cost = $f;
}

function showCost() {
return $this->cost;
}
}

$zargento = new MoreCheese;
$zargento->giveDetails("Gorgonzola", "Awful", "Green and white");
$zargento->giveCost("23.39");
echo $zargento->showType();
echo "<br>";
echo $zargento->showFlavor();
echo "<br>";
echo $zargento->showColor();
echo "<br>";
echo $zargento->showCost();

?>

As you can see, even though $zargento is no longer Cheese, and is now MoreCheese, it still retains all of the methods and properties from Cheese because the MoreCheese class inherits all of them from Cheese. The advantages to inheritance are that you don't have to edit the base class (in this case Cheese). You can also override code, as this example shows.

<?php

class Cheese { // A class, shows what all cheese has
var $type; // These are a class's attributes, or properties
var $flavor; // They are sometimes called characteristics, too.
var $color; // All cheeses have these 3 properties

// These functions are called 'methods'
// It's what the cheese can do for you
// and what you can do for your cheese
function giveDetails ($thetype, $theflavor, $thecolor) {
$this->type = $thetype;
$this->flavor = $theflavor;
$this->color = $thecolor;
}

function showType() {
return $this->type;
}
function showColor() {
return $this->color;
}
function showFlavor() {
return $this->flavor;
}
}

class MoreCheese extends Cheese {
var $cost;

function giveDetails($q) {
echo $q;
}

function giveCost($f) {
$this->cost = $f;
}

function showCost() {
return $this->cost;
}
}

$zargento = new MoreCheese;
$zargento->giveDetails("dilly");
$zargento->giveCost("23.39");
echo $zargento->showType();
echo "<br>";
echo $zargento->showFlavor();
echo "<br>";
echo $zargento->showColor();
echo "<br>";
echo $zargento->showCost();

?>

As you can see, the giveDetails() function of the base class Cheese has been overrided by the giveDetails() function of the MoreCheese class. This is a very useful feature of inheritance.

Thank you for reading this part of the tutorial, and I hope you learned something

Installing a LAMP Stack on Ubuntu Using APT


This is to help people set-up and install a LAMP (Linux-Apache-MySQL-PHP) stack in Ubuntu, including Apache 2, PHP 5 and MySQL 5.0. You can actually do it with one line of commands but since that’s not the point, let’s go step by step.
Installing Apache 2

open up the Terminal and then type this line:

sudo apt-get install apache2 apache2-utils

To restart the server
sudo /etc/init.d/apache2 restart

Browse to http://localhost , you should see displayed a text message “it works”

By default, your document root folder is located at : /var/www/ . Out of the box, you won’t have write permission to this folder, so first of all we need to change that by changing the ownership of the folder to your user.

At a terminal, do the following (replacing salimane with your login name):

sudo chown -R salimane /var/www

By default, Ubuntu’s Apache 2 will ignore the directives in your .htaccess files. To make .htaccess files work as expected, you need to edit the file /etc/apache2/sites-available/default (sometimes /etc/apache2/sites-available/000-default)
Look for a section that looks like this:

<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
# Uncomment this directive is you want to see apache2's
# default start page (in /apache2-default) when you go to /
#RedirectMatch ^/$ /apache2-default/
</Directory>

You need to modify the line containing “AllowOverride None” to read “AllowOverride All”. This tells Apache that it’s okay to allow .htaccess files to over-ride previous directives.

You must reload Apache before this change will have an effect:

sudo /etc/init.d/apache2 reload

Installing MySQL Server

open up the Terminal and then type this line:

sudo apt-get install mysql-server

In order for other computers on your network to view the server you have created, you must first edit the “Bind Address”. Begin by opening up Terminal to edit the MySQL configuration file my.cnf .

gksudo gedit /etc/mysql/my.cnf

remove or comment out the line

bind-address = 127.0.0.1
and restart mysql server with :

sudo /etc/init.d/mysql restart

Installing PHP5

open up the Terminal and then type this line:

sudo apt-get install php5

Installing PHP5 module for apache2

open up the Terminal and then type this line:

sudo apt-get install libapache2-mod-php5

In order for PHP to work and be compatible with Apache we must restart it. Type the following code in Terminal to do this:

sudo /etc/init.d/apache2 restart

To ensure there are no issues with PHP let’s give it a quick test run. In the terminal copy/paste the following line:

echo "<?php phpinfo(); ?>" > /var/www/phpinfo.php

Now open your web browser and type the following into the web address: http://localhost/phpinfo.php

Installing MySQL module for PHP5

open up the Terminal and then type this line:

sudo apt-get install php5-mysql mysql-client

then edit the PHP configuration file php.ini and uncomment the following line by taking out the semicolon (;).
Change this line:

;extension=mysql.so

To look like this:

extension=mysql.so

Now just restart Apache and you are all set!

sudo /etc/init.d/apache2 restart

Installing PHPMyAdmin

One of the easiest ways to manage your new MySQL database server is to use the graphical tool PHPMyAdmin.
Simply go to your terminal again and enter the following command:

sudo apt-get install phpmyadmin libapache2-mod-auth-mysql

Restart Apache :

sudo /etc/init.d/apache2 restart

Now just point your browser at http://localhost/phpmyadmin/.

Installing some useful modules in PHP

If you have installed xampp for Linux you will see that by default they are already some modules installed for you . But unfortunately for the default lamp stack in Ubuntu it’s not, so let’s install those common used modules in php like gd,pear,curl,memcache,xmlrpc,xsl…

sudo apt-get install php5-dev php5-gd php-pear php5-curl php5-memcache php5-xmlrpc php5-xsl php5-imagick php5-mcrypt php5-mhash

Restart Apache

sudo /etc/init.d/apache2 restart

Use regular expressions in MySQL SELECT statements


A very cool and powerful capability in MySQL and other databases is the ability to incorporate regular expression syntax when selecting data. The regular expresion support in MySQL is extensive. This recipe reviews regular expression use in MySQL and lists the supported regular expression metacharacters.

The basic syntax to use regular expressions in a MySQL query is:

SELECT something FROM table WHERE column REGEXP 'regexp'

For example, to select all columns from the table events where the values in the column id end with 5587, use:

SELECT * FROM events WHERE id REGEXP '5587$'

A more elaborate example selects all columns of the table reviews where the values in the column description contain the word excellent:

SELECT * FROM reviews WHERE description REGEXP '[[:<:]]excellent[[:>:]]'

MySQL allows the following regular expression metacharacters:

. match any character ? match zero or one
* match zero or more
+ match one or more
{n} match n times
{m,n} match m through n times
{n,} match n or more times
^ beginning of line
$ end of line
[[:<:]] match beginning of words
[[:>:]] match ending of words
[:class:] match a character class
i.e., [:alpha:] for letters
[:space:] for whitespace
[:punct:] for punctuation
[:upper:] for upper case letters
[abc] match one of enclosed chars
[^xyz] match any char not enclosed
| separates alternatives

MySQL interprets a backslash (\) character as an escape character. To use a backslash in a regular expression, you must escape it with another backslash (\\).

Wednesday, October 17, 2012

Database Normalization - MySQL

What's Database Normalization ?

Normalization is the process where a database is designed in a way that removes redundancies, and increases the clarity in organizing data in a database.
In easy English, it means take similar stuff out of a collection of data and place them into tables. Keep doing this for each new table recursively and you'll have a Normalized database. From this resultant database you should be able to recreate the data into it's original state if there is a need to do so.
The important thing here is to know when to Normalize and when to be practical. That will come with experience. For now, read on...
Normalization of a database helps in modifying the design at later times and helps in being prepared if a change is required in the database design. Normalization raises the efficiency of the datatabase in terms of management, data storage and scalability.
Now Normalization of a Database is achieved by following a set of rules called 'forms' in creating the database.
These rules are 5 in number (with one extra one stuck in-between 3&4) and they are:

1st Normal Form or 1NF:

Each Column Type is Unique.

2nd Normal Form or 2NF:

The entity under consideration should already be in the 1NF and all attributes within the entity should depend solely on the entity's unique identifier.

3rd Normal Form or 3NF:

The entity should already be in the 2NF and no column entry should be dependent on any other entry (value) other than the key for the table.
If such an entity exists, move it outside into a new table.
Now if these 3NF are achieved, the database is considered normalized. But there are three more 'extended' NF for the elitist.
These are:

BCNF (Boyce & Codd):

The database should be in 3NF and all tables can have only one primary key.

4NF:

Tables cannot have multi-valued dependencies on a Primary Key.

5NF:

There should be no cyclic dependencies in a composite key. Trying to find website design company softnep ? Check out this page: http://www.softnep.com
Well this is a highly simplified explanation for Database Normalization. One can study this process extensively though. After working with databases for some time you'll automatically create Normalized databases. As, it's logical and practical.

Monday, May 21, 2012

PHP Interview Questions and Answers


1.   What does a special set of tags <?= and ?> do in PHP?
The output is displayed directly to the browser.
2.   What’s the difference between include and require?
It’s how they handle failures. If the file is not found by require(), it will cause a fatal error and halt the execution of the script. If the file is not found by include(), a warning will be issued, but execution will continue.
3.   I am trying to assign a variable the value of 0123, but it keeps coming up with a different number, what’s the problem?
PHP Interpreter treats numbers beginning with 0 as octal. Look at the similar PHP interview questions for more numeric problems.
4.   Would I use print "$a dollars" or "{$a} dollars" to print out the amount of dollars in this example?
In this example it wouldn’t matter, since the variable is all by itself, but if you were to print something like "{$a},000,000 mln dollars", then you definitely need to use the braces.
5.   How do you define a constant?
Via define() directive, like define ("MYCONSTANT", 100);
6.   How do you pass a variable by value?
Just like in C++, put an ampersand in front of it, like $a = &$b
7.   Will comparison of string "10" and integer 11 work in PHP?
Yes, internally PHP will cast everything to the integer type, so numbers 10 and 11 will be compared.
8.   When are you supposed to use endif to end the conditional statement?
When the original if was followed by : and then the code block without braces.
9.   Explain the ternary conditional operator in PHP?
Expression preceding the ? is evaluated, if it’s true, then the expression preceding the : is executed, otherwise, the expression following : is executed.
10.                How do I find out the number of parameters passed into function?
func_num_args() function returns the number of parameters passed in.

Sunday, May 13, 2012

PHP OOPS Interview Questions & Answers


1) Explain what is object oriented programming language?
Object oriented programming language allows concepts such as modularity, encapsulation, polymorphism and inheritance.  Objects are said to be the most important part of object oriented language. Concept revolves around making simulation programs around an object. Organize a program around its data (object)& set well define interface to that data. i.e. objects and a set of well defined interfaces to that data. OOP is the common abbreviation for Object-Oriented Programming.  OOps have many properties such as DataHiding,Inheritence,Data Absraction,Data Encapsulation and many more.
2) Name some languages which have object oriented language and characteristics?
Some of the languages which have object oriented languages present in them are ABAP, ECMA Script, C++, Perl, LISP, C#, Tcl, VB, Ruby, Python, PHP, etc. Popularity of these languages has increased considerably as they can solve complex problems with ease.
3) Explain about UML?
UML or unified modeling language is regarded to implement complete specifications and features of object oriented language. Abstract design can be implemented in object oriented programming languages. It lacks implementation of polymorphism on message arguments which is a OOPs feature.
4) Explain the meaning of object in object oriented programming?
Languages which are called as object oriented almost implement everything in them as objects such as punctuations, characters, prototypes, classes, modules, blocks, etc. They were designed to facilitate and implement object oriented methods.
5) Explain about message passing in object oriented programming?
Message passing is a method by which an object sends data to another object or requests other object to invoke method. This is also known as interfacing. It acts like a messenger from one object to other object to convey specific instructions.
6) State about Java and its relation to Object oriented programming?
Java is widely used and its share is increasing considerably which is partly due to its close resemblance to object oriented languages such as C++. Code written in Java can be transported to many different platforms without changing it. It implements virtual machine.
7) What are the problems faced by the developer using object oriented programming language?
These are some of the problems faced by the developer using object oriented language they are: -
a) Object oriented uses design patterns which can be referred to as anything in general.
b) Repeatable solution to a problem can cause concern and disagreements and it is one of the major problems in software design.
8 ) State some of the advantages of object oriented programming?
Some of the advantages of object oriented programming are as follows: -
a) A clear modular structure can be obtained which can be used as a prototype and it will not reveal the mechanism behind the design. It does have a clear interface.
b) Ease of maintenance and modification to the existing objects can be done with ease.
c) A good framework is provided which facilitates in creating rich GUI applications.
9 ) Explain about inheritance in OOPS?
Objects in one class can acquire properties of the objects in other classes by way of inheritance. Reusability which is a major factor is provided in object oriented programming which adds features to a class without modifying it. New class can be obtained from a class which is already present.

10) Explain about the relationship between object oriented programming and databases?
Object oriented programming and relational database programming are almost similar in software engineering. RDBMS will not store objects directly and that’s where object oriented programming comes into play. Object relational mapping is one such solution.
11) Explain about a class in OOP?
In Object oriented programming usage of class often occurs. A class defines the characteristics of an object and its behaviors. This defines the nature and functioning of a specified object to which it is assigned. Code for a class should be encapsulated.
12) Explain the usage of encapsulation?
Encapsulation specifies the different classes which can use the members of an object. The main goal of encapsulation is to provide an interface to clients which decrease the dependency on those features and parts which are likely to change in future. This facilitates easy changes to the code and features.
13) Explain about abstraction?
Abstraction can also be achieved through composition. It solves a complex problem by defining only those classes which are relevant to the problem and not involving the whole complex code into play.
14) Explain what a method is?
A method will affect only a particular object to which it is specified. Methods are verbs meaning they define actions which a particular object will perform. It also defines various other characteristics of a particular object.
15) Name the different Creational patterns in OO design?
There are three patterns of design out of which Creational patterns play an important role the various patterns described underneath this are: -
a) Factory pattern
b) Single ton pattern
c) Prototype pattern
d) Abstract factory pattern
e) Builder pattern
16) Explain about realistic modeling?
As we live in a world of objects, it logically follows that the object oriented approach models the real world accurately. The object oriented approach allows you to identify entities as objects having attributes and behavior.
17) Explain about the analysis phase?
The anlaysis or the object oriented analysis phase considers the system as a solution to a problem in its environment or domain. Developer concentrates on obtaining as much information as possible about the problem. Critical requirements needs to be identified.

Friday, April 27, 2012

ESSENTIAL PLUGINS FOR WORDPRESS BEGINNERS – WORDPRESS TIP


So if you are a beginner in WordPress or you want a quick cheat sheet on what plugins to install here are some of my recommendations:
  1. Google XML Sitemaps:This plugin is a must. It will automatically generate a sitemap of your WordPress blog. As a beginner in WordPress this is very helpful because you won't have to deal with any code or any xml generation to get the Sitemap file. If you don't know what the sitemap.xml file is used for I will explain to you. The sitemap.xml file will allow your blog to reveal a Site Map of all your internal pages so that search engines such as google can get a deep analysis of every single page in your site and index you appropriately. This is an essential plugin when beginning a new WordPress blog.
  2. iRobots SEOThe robots.txt file gives instructions to the search engines on what to index and what to skip (for example you don't want your wp-admin zone to be indexed). This essential plugin will be great for a WordPress beginner or new blog since it will have default setups that will take care of the most important variables in a properly written robots.txt file.
  3. Google AnalyticatorThis is a very simple but efficient plugin to install on a new wordpress site. It will allow you to connect your Google Analytics website as well as to setup easily some options for it. Have you ever not wanted to track your own visits to your WordPress blog? This essential plugin for wordpress will allow you to block yourself easily from the settings page of the plugin once installed.
  4. Yoast WordPress SEOThis is one of the best plugins I have found lately for Search engine optimization. Definitely a must install in a new WordPress blog or website. This plugin will provide you the essential options to adjust how your website is exposed to search engines. It will also provide you a very intuitive way of adding your meta description, title tag and keywords to any post while at the same time giving you advise on how to do it appropriately. I used other plugins before and discovered this one recently and as a geek I can tell you its a fundamental plugin to install.
  5. Akismet
    This comes with WordPress but many people just ignore it. This will give you a protective barrier against spam comments on your website. To activate it you just go to Akismet and register. After you do this they will provide you an API key that you will be able to insert in the Akismet plugin settings
  6. Permalink EditorPermalinks are the URL of your blog posts or pages. WordPress by default lets you setup a standard or dynamic structure. However to get further customization options, this plugin is beautiful. It will enable a "Customize" button beside your URL when editing blog posts. Have you ever wanted to change the category in which the URL is appearing or just change the text? This plugin will allow you to do that easily.
  7. Comprehensive Google Map Plugin (Extra but not essential)This is not for every blog, but just in case you want to use a map in your site to show your location, business venues or any other thing its a personally favorite one. I install this in almost every blog I setup in WordPress since the plugin will be eventually used at some point.
That's it. I was talking about essential plugins not the top 5, 10 or 15 WordPress plugins. These plugins will allow any beginner to have its blog setup with proper SEO, sitemap, robot file and other options to make the most of its content.
If you are a setting up your new site, I would also suggest you read these posts as well:
Visit taxiwaltononthames to find out more regarding taxis walton on thames