tag:blogger.com,1999:blog-60772421247090457562024-02-18T18:18:57.198-08:00My Programming LifeThis blog is about my Development ExperiencesLasanthahttp://www.blogger.com/profile/17007166390115409126noreply@blogger.comBlogger36125tag:blogger.com,1999:blog-6077242124709045756.post-26718217863310941942016-05-23T08:30:00.002-07:002016-05-24T21:57:42.696-07:00Git script which shows little bit advanced status.
Save with Preferred file name in /usr/local/bin/XX
<pre>
branch=""
branches="git branch --list"
ESC_SEQ="\x1b["
COL_RESET=$ESC_SEQ"39;49;00m"
COL_RED=$ESC_SEQ"31;01m"
while read -r branch; do
clean_branch_name=${branch//\*\ /}
description=`git config branch.$clean_branch_name.description`
if [ "${branch::1}" == "*" ]; then
printf "$COL_RED$branch$COL_RESET $description \n"
else
printf " $branch $description\n"
fi
done <<< "$branches"
git status
</pre>
Use the following command to add a description to your local branches.
<pre>
git branch --edit-description
</pre>Lasanthahttp://www.blogger.com/profile/17007166390115409126noreply@blogger.com0tag:blogger.com,1999:blog-6077242124709045756.post-81093564724860997472016-04-02T05:17:00.002-07:002016-04-02T05:17:53.406-07:00SQL Result as CSVSELECT * FROM core_config_data INTO OUTFILE '/tmp/core_config.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '`' LINES TERMINATED BY '\n';Lasanthahttp://www.blogger.com/profile/17007166390115409126noreply@blogger.com0tag:blogger.com,1999:blog-6077242124709045756.post-46696544498319110292015-12-15T17:52:00.002-08:002015-12-15T17:55:29.009-08:00Dual Screen Script for Ubuntu<div dir="ltr" style="text-align: left;" trbidi="on">
I have experienced problems when installing two monitors in Ubuntu. Following script will help you to solve this problem.
I had problems when saving below values so I created a script and put it to the startup.
<br />
<pre>#!/bin/sh
xrandr --output VGA-0 --mode 1920x1080 --pos 1280x0 --rotate normal --output DVI-I-1 --off --output DVI-I-0 --mode 1280x1024 --pos 0x0 --rotate normal --output HDMI-0 --off
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-iLX4mM2BvfscBq0uF8Ihv_POoKvN-aw9gXZ4lMl4Au1yh6NiXRMombjRcAa-JkDL48nhFHS2Nj-RrsgmD9jTQsf60JnzV8xtL0DRCcsulSpKJQBQLiAT8FrQxvPXaf18x_J8ohaigEs/s1600/Display_055.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-iLX4mM2BvfscBq0uF8Ihv_POoKvN-aw9gXZ4lMl4Au1yh6NiXRMombjRcAa-JkDL48nhFHS2Nj-RrsgmD9jTQsf60JnzV8xtL0DRCcsulSpKJQBQLiAT8FrQxvPXaf18x_J8ohaigEs/s320/Display_055.png" width="256" /></a></div>
</pre>
</div>
Lasanthahttp://www.blogger.com/profile/17007166390115409126noreply@blogger.com0tag:blogger.com,1999:blog-6077242124709045756.post-70146071245504036662014-08-26T18:59:00.000-07:002014-08-26T19:01:54.172-07:00MYSQL Compare data in different Databases<div dir="ltr" style="text-align: left;" trbidi="on">
Following statement will compare values in two databases and gives you records that not matched.<br />
<br />
<pre>SELECT stage,live,path,scope_id FROM
(
SELECT
(CASE
WHEN (S.value = L.value) THEN ''
ELSE 'N/M'
END) as matched,
S.scope_id,
S.path,
S.value AS 'stage',
L.value AS 'live'
FROM
cin_stage.core_config_data S
INNER JOIN
cin_live.core_config_data L ON S.path = L.path
) RES
WHERE matched = 'N/M'
ORDER BY scope_id
</pre>
</div>
Lasanthahttp://www.blogger.com/profile/17007166390115409126noreply@blogger.com0tag:blogger.com,1999:blog-6077242124709045756.post-53891622962146268542014-08-07T22:23:00.000-07:002014-08-26T18:57:30.047-07:00Magento DB access denied<div dir="ltr" style="text-align: left;" trbidi="on">
I got this error suddenly while accessing the magento site. <br />
<br />
SQLSTATE[HY000] [1129] Host 'user.workgroup' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'<br />
<br />
Solution<br />
<br />
use below command in console<br />
<br />
<pre>mysqladmin flush-hosts</pre><br />
<br />
or log in to mysql with a different host if its implemented on network environment and use below statement;<br />
<br />
<pre>FLUSH HOSTS;</pre><br />
<br />
<br />
Or<br />
<br />
<br />
Restart the mysql server<br />
<br />
<br /></div>
Lasanthahttp://www.blogger.com/profile/17007166390115409126noreply@blogger.com0tag:blogger.com,1999:blog-6077242124709045756.post-26961804785164496222014-07-28T20:40:00.003-07:002014-08-26T19:04:35.346-07:00PHP URL Checker using CSV<pre>
<?php
/*
| File: url_checker.php
| Info: Take CSV as inpu and check url status.
| Usage: php url_checker.php
|
| CSV file contain URLS
|
| ex:
| www.site.com/url1
| www.site.com/url2
| www.site.com/url3
| www.site.com/url4
| www.site.com/url5
| www.site.com/url6
| www.site.com/url7
|
*/
$file = fopen("urls.csv","r");
while(! feof($file))
{
$row = fgetcsv($file);
$handle = curl_init($row[0]);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, TRUE);
$response = curl_exec($handle);
$httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
if($httpCode!=200)
{
//Following will use teminal colors to
echo "\033[01;31m{$httpCode} \033[0m {$row[0]} \n";
}
else
{
echo $httpCode."\n";
}
}
echo "Finished fetching...";
fclose($file);
?>
</pre>Lasanthahttp://www.blogger.com/profile/17007166390115409126noreply@blogger.com0tag:blogger.com,1999:blog-6077242124709045756.post-55272977059768090792014-07-13T21:05:00.003-07:002014-07-13T21:05:22.279-07:00Magento Generate Google Sitemap using Cron<div dir="ltr" style="text-align: left;" trbidi="on">
I had a problem with generating the Google sitemap using cron job. To do that you can simply change following database value.<br />
<span style="color: #38761d;"><br /></span>
<br />
<pre><span style="color: #38761d;">SELECT * FROM core_config_data
WHERE path = 'crontab/jobs/sitemap_generate/schedule/cron_expr'</span></pre>
<br />
<br />
Change the value as you set time in cron jobs.<br />
<br />
EX: Generate the Sitemap for every 5 minutes<br />
<br />
<pre><span style="color: #38761d;">value = */5 * * * *</span></pre>
<br />
<br />
That's it. Now you have to worry about cron is working or not. Just type following in your browser and hit enter.<br />
<br />
<span style="color: #38761d;"><br /></span>
<span style="color: #38761d;">http://youresite.com/cron.php</span><br />
<br />
<br />
<br /></div>
Lasanthahttp://www.blogger.com/profile/17007166390115409126noreply@blogger.com0tag:blogger.com,1999:blog-6077242124709045756.post-66222932434432589342014-03-14T09:37:00.002-07:002014-03-14T09:37:40.577-07:00Delete Order details from Magento<pre>
SET FOREIGN_KEY_CHECKS=0;
TRUNCATE `sales_flat_creditmemo`;
TRUNCATE `sales_flat_creditmemo_comment`;
TRUNCATE `sales_flat_creditmemo_grid`;
TRUNCATE `sales_flat_creditmemo_item`;
TRUNCATE `sales_flat_invoice`;
TRUNCATE `sales_flat_invoice_comment`;
TRUNCATE `sales_flat_invoice_grid`;
TRUNCATE `sales_flat_invoice_item`;
TRUNCATE `sales_flat_order`;
TRUNCATE `sales_flat_order_address`;
TRUNCATE `sales_flat_order_grid`;
TRUNCATE `sales_flat_order_item`;
TRUNCATE `sales_flat_order_payment`;
TRUNCATE `sales_flat_order_status_history`;
TRUNCATE `sales_flat_quote`;
TRUNCATE `sales_flat_quote_address`;
TRUNCATE `sales_flat_quote_address_item`;
TRUNCATE `sales_flat_quote_item`;
TRUNCATE `sales_flat_quote_item_option`;
TRUNCATE `sales_flat_quote_payment`;
TRUNCATE `sales_flat_quote_shipping_rate`;
TRUNCATE `sales_flat_shipment`;
TRUNCATE `sales_flat_shipment_comment`;
TRUNCATE `sales_flat_shipment_grid`;
TRUNCATE `sales_flat_shipment_item`;
TRUNCATE `sales_flat_shipment_track`;
TRUNCATE `sales_invoiced_aggregated`;
TRUNCATE `sales_invoiced_aggregated_order`;
TRUNCATE `sales_order_aggregated_created`;
TRUNCATE `log_quote`;
TRUNCATE `report_event`;
ALTER TABLE `sales_flat_creditmemo` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_creditmemo_comment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_creditmemo_grid` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_creditmemo_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_invoice` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_invoice_comment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_invoice_grid` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_invoice_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_address` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_grid` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_payment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_status_history` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_address` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_address_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_item_option` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_payment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_shipping_rate` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment_comment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment_grid` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment_track` AUTO_INCREMENT=1;
ALTER TABLE `sales_invoiced_aggregated` AUTO_INCREMENT=1;
ALTER TABLE `sales_invoiced_aggregated_order` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_aggregated_created` AUTO_INCREMENT=1;
ALTER TABLE `log_quote` AUTO_INCREMENT=1;
ALTER TABLE `report_event` AUTO_INCREMENT=1;
SET FOREIGN_KEY_CHECKS=1;
</pre>Lasanthahttp://www.blogger.com/profile/17007166390115409126noreply@blogger.com0tag:blogger.com,1999:blog-6077242124709045756.post-6235283683665283892014-03-13T07:58:00.001-07:002014-03-13T07:58:41.035-07:00Delete Customer Details from Magee using SQL<pre>
SET FOREIGN_KEY_CHECKS=0;
-- reset customers
TRUNCATE customer_address_entity;
TRUNCATE customer_address_entity_datetime;
TRUNCATE customer_address_entity_decimal;
TRUNCATE customer_address_entity_int;
TRUNCATE customer_address_entity_text;
TRUNCATE customer_address_entity_varchar;
TRUNCATE customer_entity;
TRUNCATE customer_entity_datetime;
TRUNCATE customer_entity_decimal;
TRUNCATE customer_entity_int;
TRUNCATE customer_entity_text;
TRUNCATE customer_entity_varchar;
TRUNCATE log_customer;
TRUNCATE log_visitor;
TRUNCATE log_visitor_info;
ALTER TABLE customer_address_entity AUTO_INCREMENT=1;
ALTER TABLE customer_address_entity_datetime AUTO_INCREMENT=1;
ALTER TABLE customer_address_entity_decimal AUTO_INCREMENT=1;
ALTER TABLE customer_address_entity_int AUTO_INCREMENT=1;
ALTER TABLE customer_address_entity_text AUTO_INCREMENT=1;
ALTER TABLE customer_address_entity_varchar AUTO_INCREMENT=1;
ALTER TABLE customer_entity AUTO_INCREMENT=1;
ALTER TABLE customer_entity_datetime AUTO_INCREMENT=1;
ALTER TABLE customer_entity_decimal AUTO_INCREMENT=1;
ALTER TABLE customer_entity_int AUTO_INCREMENT=1;
ALTER TABLE customer_entity_text AUTO_INCREMENT=1;
ALTER TABLE customer_entity_varchar AUTO_INCREMENT=1;
ALTER TABLE log_customer AUTO_INCREMENT=1;
ALTER TABLE log_visitor AUTO_INCREMENT=1;
ALTER TABLE log_visitor_info AUTO_INCREMENT=1;
SET FOREIGN_KEY_CHECKS=1;
</pre>Lasanthahttp://www.blogger.com/profile/17007166390115409126noreply@blogger.com0tag:blogger.com,1999:blog-6077242124709045756.post-23992607682926051792013-10-30T02:57:00.001-07:002013-10-30T02:57:14.199-07:00Delete Magento images programmatically<pre>
$productId =1;
$loadpro=Mage::getModel('catalog/product')->load($product->getId());
$mediaApi = Mage::getModel("catalog/product_attribute_media_api");
$mediaApiItems = $mediaApi->items($product->getId());
foreach($mediaApiItems as $item)
{
$mediaApi->remove($loadpro->getId(), $item['file']);
}
$loadpro->save();
</pre>Lasanthahttp://www.blogger.com/profile/17007166390115409126noreply@blogger.com0tag:blogger.com,1999:blog-6077242124709045756.post-56281952179084537662013-08-06T02:49:00.000-07:002013-08-06T02:49:13.122-07:00Search column name from MYSQL database<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
SELECT table_name,column_name,table_schema<br />FROM INFORMATION_SCHEMA.COLUMNS<br />WHERE column_name like '%mail%'<br /><br /></div>
Lasanthahttp://www.blogger.com/profile/17007166390115409126noreply@blogger.com0tag:blogger.com,1999:blog-6077242124709045756.post-3620376989695674412013-07-11T00:10:00.001-07:002013-07-11T00:10:54.100-07:00TORA SQL In UBUNTU<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Verdana, sans-serif;">I have used DbVisualizer 9.0 in Ubuntu 13.04. Because of that I cannot use other software like netbeans and chrome due to slowness of their process. So I moved to different Mysql Admin tools and Tora is great tool.</span><br />
<span style="font-family: Verdana, sans-serif;"><br />
<a href="http://torasql.com/">http://torasql.com/</a></span><br />
<span style="font-family: Verdana, sans-serif;"><br />
here is how you can install it in Ubuntu</span><br />
<br />
$ sudo apt-get install tora<br />
$ sudo apt-get install libqt4-sql-mysql libqt4-sql-psql libqt4-sql-sqlite libqt4-sql-odbc libqt4-sql-tds</div>
Lasanthahttp://www.blogger.com/profile/17007166390115409126noreply@blogger.com0tag:blogger.com,1999:blog-6077242124709045756.post-29221480231845956262013-02-02T07:34:00.000-08:002013-02-02T07:34:55.646-08:00Cheap Web Hosting<div dir="ltr" style="text-align: left;" trbidi="on">
I just want to mention here I found some of my friends offering cheap web hosting in fiverr. Checkout their gigs. They offer following options for $5. Its Cheap I guess. Why don't you give a try<br />
<br />
Below are the links to those gigs. You can pay them via Paypal<br />
<br />
<a href="http://fiverr.com/calestomedia/provide-a-genuine-5-websites-hosting-package-for-1-year-including-cpanel-fantastico-sitebuilder-500-free-templates">http://fiverr.com/calestomedia/provide-a-genuine-5-websites-hosting-package-for-1-year-including-cpanel-fantastico-sitebuilder-500-free-templates</a><br />
<br />
<a href="http://fiverr.com/llcoollasa/give-you-100mb-hosting-space">http://fiverr.com/llcoollasa/give-you-100mb-hosting-space</a><br />
<br />
<br /></div>
Lasanthahttp://www.blogger.com/profile/17007166390115409126noreply@blogger.com0tag:blogger.com,1999:blog-6077242124709045756.post-19814207763805357632012-10-16T00:15:00.001-07:002012-10-16T00:39:50.462-07:00Use Default Value in Product Magento<div dir="ltr" style="text-align: left;" trbidi="on">
<style>
pre {
background-color: #FAFAFA;
font-size: 9pt;
line-height: 125%;
margin: 1em 0 0;
overflow: auto;
padding: 0.99em;
word-wrap: break-word;
}
code, pre {
color: #007000;
font-family: monospace;
}
.tag {
color: #000088;
}
.pln {
color: #000000;
}
.com {
color: #880000;
}
.atn {
color: #660066;
}
.pun {
color: #666600;
}
.atv {
color: #008800;
}
.kwd {
color: #000088;
}
.typ {
color: #660066;
}
.str {
color: #008800;
}
</style>
<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<span class="Apple-style-span" style="font-size: large;">Again I Spent quiet time to set `Use Default Value` in Magento. </span><br />
<span class="Apple-style-span" style="font-size: large;"><br /></span>
<span class="Apple-style-span" style="font-size: large;">I wanted to set Product Status to be `Use Default Value` under store views. I tried some methods and checked not lucky for me so i tested with the database.</span><br />
<span class="Apple-style-span" style="font-size: large;"></span><br />
<a name='more'></a><span class="Apple-style-span" style="font-size: large;"><br />
SELECT * FROM catalog_product_entity_int WHERE store_id =4 and entity_id =1 </span><br />
<span class="Apple-style-span" style="font-size: large;"><br />
I found when we enable `Use Default Value` there is a record for status (my status id was 96. You can find them from eav_attribute table )</span><br />
<span class="Apple-style-span" style="font-size: large;"><br />
When it is disabled there is no record. So i thought do that by Database wise. But its not good at all so I found this. Finally it worked.</span><br />
<span class="Apple-style-span" style="font-size: large;"><br /></span></div>
<pre>Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$product = Mage::getModel('catalog/product')
->load($pro_id)
->setStoreId($store_view)
->setData('status', false)
->save();
</pre>
<br />
<span class="Apple-style-span" style="font-size: large;">You can use `Use Default Value` to supported attributes but don't forget to add <br />
</span><br />
<pre><span class="Apple-style-span" style="font-size: large;">Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);</span></pre>
<span class="Apple-style-span" style="font-size: large;"><br />
Otherwise only putting<br /><pre>setData('status', false); </pre>
<br /> won't work
</span></div>
</div>
Lasanthahttp://www.blogger.com/profile/17007166390115409126noreply@blogger.com0tag:blogger.com,1999:blog-6077242124709045756.post-46893742271020896252012-07-18T11:04:00.002-07:002012-10-16T00:28:19.571-07:00MYSQL INSERT OR UPDATE in Single SQL Statement<div dir="ltr" style="text-align: left;" trbidi="on">
You might want to update or insert Database single statement rather than checking the record is inserted or and again go to the update.<br />
<div>
<br /></div>
<div>
But using following SQL statement you can run First run and check Insert statement and if that fails Update statement after that.</div>
<div>
<br />
<a name='more'></a><br /></div>
<div>
Assume my table structure as follows</div>
<div>
<br />
Create the sample table as below<br />
<br /></div>
<div>
<br />
CREATE TABLE IF NOT EXISTS `tbl_test` (<br />
<br />
cat_id int AUTO_INCREMENT,<br />
name varchar(50),<br />
primary key(cat_id)<br />
<br />
)</div>
<div>
<br />
add some records to tbl_test<br />
<br />
<br />
INSERT INTO tbl_test (name) VALUES ('cat 111'),('cat 2'),('cat 3');<br />
<br />
<br />
and finally you can update the record or insert by following<br />
<br /></div>
<div>
<div>
<br />
INSERT INTO tbl_test (cat_id,name) VALUES (1,'
cat 1 ')<br />
ON DUPLICATE KEY UPDATE name='
cat 1 '</div>
<div>
<br />
That's IT.<br />
<br />
Cheers</div>
</div>
</div>
Lasanthahttp://www.blogger.com/profile/17007166390115409126noreply@blogger.com0tag:blogger.com,1999:blog-6077242124709045756.post-43288287275687158092012-06-03T22:34:00.000-07:002012-10-16T00:30:41.338-07:00Override Magento Module MD5 to SHA1<div dir="ltr" style="text-align: left;" trbidi="on">
<style>
pre {
background-color: #FAFAFA;
font-size: 9pt;
line-height: 125%;
margin: 1em 0 0;
overflow: auto;
padding: 0.99em;
word-wrap: break-word;
}
code, pre {
color: #007000;
font-family: monospace;
}
.tag {
color: #000088;
}
.pln {
color: #000000;
}
.com {
color: #880000;
}
.atn {
color: #660066;
}
.pun {
color: #666600;
}
.atv {
color: #008800;
}
.kwd {
color: #000088;
}
.typ {
color: #660066;
}
.str {
color: #008800;
}
</style>
<br />
<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal">
</div>
<div class="MsoNormal">
Override Magento Module MD5 to SHA1</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Here I am going to override the hash function in Encryption
class to sha1 instead of md5.</div>
<div class="MsoNormal">
Original file is located in below path.</div>
<div class="MsoNormal">
<br />
<a name='more'></a><br /><br />
<b>\app\code\core\Mage\Core\Model\Encryption.php.</b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
To override above function I will follow standards given by Magento.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
First I will create the directory structure.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
For this example I will use MyNameSpace as my Module name</div>
<div class="MsoNormal">
<br /></div>
<b>
</b>
<div class="MsoNormal">
<b>\app\code\local\MyNameSpace\MyModule</b></div>
<b>
<div class="MsoNormal">
\app\code\local\MyNameSpace\MyModule\Block</div>
<div class="MsoNormal">
\app\code\local\MyNameSpace\MyModule\controllers </div>
<div class="MsoNormal">
\app\code\local\MyNameSpace\MyModule\etc</div>
<div class="MsoNormal">
\app\code\local\MyNameSpace\MyModule\Helper</div>
<div class="MsoNormal">
\app\code\local\MyNameSpace\MyModule\Model</div>
<div class="MsoNormal">
\app\code\local\MyNameSpace\MyModule\sql</div>
</b>
<br />
<div class="MsoNormal">
Second I am going to create the Source files which are
needed for this task.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Create the MyNameSpace_All.xml in following path and save it
with below codes.</div>
<div class="MsoNormal">
As you know this file will tells to Magento that we are
using MyModule
Module.</div>
<div class="MsoNormal">
<br />
<b>\app\etc\modules\MyNameSpace_All.xml</b></div>
</div>
<pre><?xml version="1.0"?>
<config>
<modules>
<MyNameSpace_MyModule>
<active>true</active>
<codePool>local</codePool>
</MyNameSpace_MyModule>
</modules>
</config>
</pre>
<div class="MsoNormal">
</div>
<span style="font-family: Calibri, sans-serif; font-size: 11pt; line-height: 115%;"><br clear="all" style="mso-special-character: line-break; page-break-before: always;" />
</span>
<br />
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Add the following codes in below file (you have to create as
normally do).</div>
<div class="MsoNormal">
<i>config.xml explain using xml comments </i><span style="font-family: Wingdings;">J</span>.<o:p></o:p></div>
<div class="MsoNormal">
<br />
<br />
<b>\app\code\local\MyNameSpace\MyModule\etc\config.xml</b></div>
<br />
<pre><?xml version="1.0"?>
<config>
<modules>
<MyNameSpace_MyModule>
<version>0.1.0</version>
<depends>
<Mage_Core />
</depends>
</MyNameSpace_MyModule>
</modules>
<global>
<models>
<core>
<rewrite>
<encryption>MyNameSpace_MyModule_Model_Encryption</encryption>
</rewrite>
</core>
</models>
<helpers>
<core>
<encryption_model>MyNameSpace_MyModule_Model_Encryption</encryption_model>
</core>
</helpers>
</global>
<frontend>
<routers>
<mynamespace_mymodule>
<use>standard</use>
<args>
<module>MyNameSpace_MyModule</module>
<frontName>mymodule</frontName>
</args>
</mynamespace_mymodule>
</routers>
</frontend>
</config>
</pre>
<br />
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Writeing the new Encryption Class which will have the new
hashing function</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b>\app\code\local\MyNameSpace\MyModule\Model\Encryption.php</b></div>
<pre><?php
class MyNameSpace_MyModule_Model_Encryption extends Mage_Core_Model_Encryption
{
public function hash($data)
{
return sha1($data);
}
}
?>
</pre>
<br />
<div class="MsoNormal">
Ok Done. You can try sha and md5 difference now. I checked
through when registering a new customer. New sha1 values located in
customer_entity_varchar table in your database. </div>
<br /></div>
Lasanthahttp://www.blogger.com/profile/17007166390115409126noreply@blogger.com1tag:blogger.com,1999:blog-6077242124709045756.post-63035832422902774162012-03-11T04:17:00.001-07:002012-10-16T00:30:27.196-07:00AJAX, Cross Domain, XMLHttpRequest, XDomainRequest Over IE8 FF8 and Chrome<div dir="ltr" style="text-align: left;" trbidi="on">
<style>
pre {
background-color: #FAFAFA;
font-size: 9pt;
line-height: 125%;
margin: 1em 0 0;
overflow: auto;
padding: 0.99em;
word-wrap: break-word;
}
code, pre {
color: #007000;
font-family: monospace;
}
.tag {
color: #000088;
}
.pln {
color: #000000;
}
.com {
color: #880000;
}
.atn {
color: #660066;
}
.pun {
color: #666600;
}
.atv {
color: #008800;
}
.kwd {
color: #000088;
}
.typ {
color: #660066;
}
.str {
color: #008800;
}
</style>
Ok.I have been faced for this cross domain request using ajax last week and i got real pain when i tried to use it. <br />
I tried with jquery ajax and read lots of articles from the Internet. Reading made me to do this post.<br />
First i tell you what was my scene. I had to do a validation regarding some value. I request this via Ajax.<br />
<br />
<br />
<a name='more'></a><br /><br />
<h2>
Problems</h2>
My Origin (requesting ajax call from)<br />
<br />
https://www.domain.com/<br />
<br />
My Validation result and requested output<br />
<br />
https://sub.domain.com<br />
<br />
<h2>
Here is the deal. Normally you cant do below</h2>
Access remote content which different from current protocol://domain.com.<br />
<i>example:</i><br />
Requesting https://<b>sub.domain.com</b> content from https://<b>www.domain.com/</b><br />
Requesting <b>http</b>://www.domain.com content from <b>https</b>://www.domain.com/<br />
Requesting http://www.domain.com:<b>80</b> content from https://www.domain.com:<b>8080</b><br />
<br />
still you have same domain and want to make a call to your sub domain....<b>No you cant</b>.<br />
Even in my sample function. I cant access https from http or https from http ONLY FOR IE8.Other browsers are working. I think you understand me.
(My next attempt would be resolve this IE8 Problem).<br />
In my function i manage to fulfill my requirement and hopefully this might help you to enhance, read or use your requirement. <br />
Anyway you can dive in the Internet to get enough details(I spend lots of time...:-P)<br />
<br />
<br />
<h4>
also you have to remember the content page your going to request should contain following header type included.</h4>
<br />
<br />
<b>Access-Control-Allow-Origin: *</b><br />
<br />
With php you can add as below <br />
<br />
<pre><?php header('Access-Control-Allow-Origin: *'); ?>
</pre>
<h2>
Here is my Code.</h2>
<pre><html>
<head>
<title>AJAX</title>
<script type="text/javascript" src="jquery-1.7.1.js"></script>
<script type="text/javascript">
var XHR ;
function createXMLHttp()
{
if (typeof XMLHttpRequest != "undefined")
{
if(window.XDomainRequest)
{
return new XDomainRequest();
}
else
{
return new XMLHttpRequest();
}
}
else if (window.ActiveXObject)
{
var aVersions = ["MSXML2.XMLHttp.5.0","MSXML2.XMLHttp.4.0","MSXML2.XMLHttp.3.0","MSXML2.XMLHttp","Microsoft.XMLHttp"];
for (var i = 0; i < aVersions.length; i++)
{
try
{
var oXmlHttp = new ActiveXObject(aVersions[i]);
return oXmlHttp;
}
catch(oError)
{
throw new Error("XMLHttp object could be created.");
}
}
}
throw new Error("XMLHttp object could be created.");
}
function makeAjaxRequest(url)
{
XHR = new createXMLHttp();
if(XHR)
{
XHR.open('GET',url, true);
//XHR.onreadystatechange = handler;
XHR.onload = function()
{
if (XHR.readyState == 4)
{
//Chrome 17 and FF 8.0
if (XHR.status == 200)
{
response =eval("("+XHR.responseText+")");
$("#res-text").html("Name : " + response.name + "<br/>Company Overview : " + response.company_overview);
}
else
{
alert("Invocation Errors Occured " + XHR.readyState + " and the status is " + XHR.status);
}
}
else
{
//IE8
response =eval("("+XHR.responseText+")");
$("#res-text").html("Name : " + response.name + "<br/>Company Overview : " + response.company_overview);
}
};
XHR.send(null);
}
else
{
alert("Cannot Make Ajax Request");
}
}
function handler(evtXHR)
{
if (XHR.readyState == 4)
{
if (XHR.status == 200)
{
response =eval("("+XHR.responseText+")");
//$("#res-text").html("Name : " + response.name + "\nCompany Overview : " + response.company_overview);
alert(response.name);
}
else
{
alert("Invocation Errors Occured " + XHR.readyState + " and the status is " + XHR.status);
}
}
else
{
//"currently the application is at" + XHR.readyState);
}
}
makeAjaxRequest('https://graph.facebook.com/19292868552');
</script>
</head>
<body style="background:#001122; color:#FFFFFF; font-size:13px;font-family:'Verdana'">
<div id="res-text" ></div>
</body>
</html><html>
<head>
<title>AJAX</title>
<script type="text/javascript" src="jquery-1.7.1.js"></script>
<script type="text/javascript">
var XHR ;
function createXMLHttp()
{
if (typeof XMLHttpRequest != "undefined")
{
if(window.XDomainRequest)
{
return new XDomainRequest();
}
else
{
return new XMLHttpRequest();
}
}
else if (window.ActiveXObject)
{
var aVersions = ["MSXML2.XMLHttp.5.0","MSXML2.XMLHttp.4.0","MSXML2.XMLHttp.3.0","MSXML2.XMLHttp","Microsoft.XMLHttp"];
for (var i = 0; i < aVersions.length; i++)
{
try
{
var oXmlHttp = new ActiveXObject(aVersions[i]);
return oXmlHttp;
}
catch(oError)
{
throw new Error("XMLHttp object could be created.");
}
}
}
throw new Error("XMLHttp object could be created.");
}
function makeAjaxRequest(url)
{
XHR = new createXMLHttp();
if(XHR)
{
XHR.open('GET',url, true);
//XHR.onreadystatechange = handler;
XHR.onload = function()
{
if (XHR.readyState == 4)
{
//Chrome 17 and FF 8.0
if (XHR.status == 200)
{
response =eval("("+XHR.responseText+")");
$("#res-text").html("Name : " + response.name + "<br/>Company Overview : " + response.company_overview);
}
else
{
alert("Invocation Errors Occured " + XHR.readyState + " and the status is " + XHR.status);
}
}
else
{
//IE8
response =eval("("+XHR.responseText+")");
$("#res-text").html("Name : " + response.name + "<br/>Company Overview : " + response.company_overview);
}
};
XHR.send(null);
}
else
{
alert("Cannot Make Ajax Request");
}
}
function handler(evtXHR)
{
if (XHR.readyState == 4)
{
if (XHR.status == 200)
{
response =eval("("+XHR.responseText+")");
//$("#res-text").html("Name : " + response.name + "\nCompany Overview : " + response.company_overview);
alert(response.name);
}
else
{
alert("Invocation Errors Occured " + XHR.readyState + " and the status is " + XHR.status);
}
}
else
{
//"currently the application is at" + XHR.readyState);
}
}
makeAjaxRequest('https://graph.facebook.com/19292868552');
</script>
</head>
<body style="background:#001122; color:#FFFFFF; font-size:13px;font-family:'Verdana'">
<div id="res-text" ></div>
</body>
</html><html>
<head>
<title>AJAX</title>
<script type="text/javascript" src="jquery-1.7.1.js"></script>
<script type="text/javascript">
var XHR ;
function createXMLHttp()
{
if (typeof XMLHttpRequest != "undefined")
{
if(window.XDomainRequest)
{
return new XDomainRequest();
}
else
{
return new XMLHttpRequest();
}
}
else if (window.ActiveXObject)
{
var aVersions = ["MSXML2.XMLHttp.5.0","MSXML2.XMLHttp.4.0","MSXML2.XMLHttp.3.0","MSXML2.XMLHttp","Microsoft.XMLHttp"];
for (var i = 0; i < aVersions.length; i++)
{
try
{
var oXmlHttp = new ActiveXObject(aVersions[i]);
return oXmlHttp;
}
catch(oError)
{
throw new Error("XMLHttp object could be created.");
}
}
}
throw new Error("XMLHttp object could be created.");
}
function makeAjaxRequest(url)
{
XHR = new createXMLHttp();
if(XHR)
{
XHR.open('GET',url, true);
//XHR.onreadystatechange = handler;
XHR.onload = function()
{
if (XHR.readyState == 4)
{
//Chrome 17 and FF 8.0
if (XHR.status == 200)
{
response =eval("("+XHR.responseText+")");
$("#res-text").html("Name : " + response.name + "<br/>Company Overview : " + response.company_overview);
}
else
{
alert("Invocation Errors Occured " + XHR.readyState + " and the status is " + XHR.status);
}
}
else
{
//IE8
response =eval("("+XHR.responseText+")");
$("#res-text").html("Name : " + response.name + "<br/>Company Overview : " + response.company_overview);
}
};
XHR.send(null);
}
else
{
alert("Cannot Make Ajax Request");
}
}
function handler(evtXHR)
{
if (XHR.readyState == 4)
{
if (XHR.status == 200)
{
response =eval("("+XHR.responseText+")");
//$("#res-text").html("Name : " + response.name + "\nCompany Overview : " + response.company_overview);
alert(response.name);
}
else
{
alert("Invocation Errors Occured " + XHR.readyState + " and the status is " + XHR.status);
}
}
else
{
//"currently the application is at" + XHR.readyState);
}
}
makeAjaxRequest('https://graph.facebook.com/19292868552');
</script>
</head>
<body style="background:#001122; color:#FFFFFF; font-size:13px;font-family:'Verdana'">
<div id="res-text" ></div>
</body>
</html>
</pre>
<br />
Read More:
<a href="http://hacks.mozilla.org/2009/07/cross-site-xmlhttprequest-with-cors/">http://hacks.mozilla.org/2009/07/cross-site-xmlhttprequest-with-cors/</a>
<br />
<br />
Leave a comment. Cheers.</div>
Lasanthahttp://www.blogger.com/profile/17007166390115409126noreply@blogger.com1tag:blogger.com,1999:blog-6077242124709045756.post-5539326146214106112011-10-16T00:39:00.000-07:002013-02-02T07:36:27.989-08:00SQL Distributed Management Objects (SQL-DMO)<div dir="ltr" style="text-align: left;" trbidi="on">
<style>
pre {
background-color: #FAFAFA;
font-size: 9pt;
line-height: 125%;
margin: 1em 0 0;
overflow: auto;
padding: 0.99em;
word-wrap: break-word;
}
code, pre {
color: #007000;
font-family: monospace;
}
.tag {
color: #000088;
}
.pln {
color: #000000;
}
.com {
color: #880000;
}
.atn {
color: #660066;
}
.pun {
color: #666600;
}
.atv {
color: #008800;
}
.kwd {
color: #000088;
}
.typ {
color: #660066;
}
.str {
color: #008800;
}
</style><span style="font-family: verdana; font-size: x-small;">A SQL-DMO object exposes the attributes of a Microsoft® SQL Server™ 2000 component.</span><br />
<div style="text-align: justify;">
<span style="font-family: verdana; font-size: x-small;">Distributed Management Objects (DMO) is a set of programmable objects that come with SQL Server that make it easy to programatically administer your databases. SQL-DMO is actually the foundation of Enterprise Manager, so you can pretty much do anything programatically that you can do in the management tools. Some of these tasks include :</span></div>
<span style="font-family: verdana; font-size: x-small;"></span><br />
<a name='more'></a><span style="font-family: verdana; font-size: x-small;"><br /></span><ui></ui>
<br />
<li>Scripting Objects </li>
<li>Backing up databases </li>
<li>Creating jobs </li>
<li>Altering tables </li>
<br />
Code snippets are from VB.NET<br />
<h4>
Connecting using SQL Authentication</h4>
<pre>Dim objDMO as SQLServer
Set objDMO = new SQLDMO.SQLServer
objDMO.Connect "(local)", "sa", "of_course_I_changed_my_password"</pre>
<span style="font-family: Georgia,serif;"><br /></span><span style="font-size: medium;"><span style="font-weight: bold;">Connecting using NT Authentication</span></span><br />
<div style="text-align: justify;">
This is as simple as setting the "loginsecure" property to <b>True</b> and leaving off the login and password.</div>
<pre>Dim objDMO as SQLServer
Set objDMO = new SQLDMO.SQLServer
objDMO.loginsecure = true
objDMO.Connect "(local)"
Don't forget at the end of this you will want to disconnect and clean up your objects with a simple :
objDMO.DisConnect
Set objDMO = nothing</pre>
<br />
<h4>
The Tables Collection</h4>
The object model within DMO is very similar to the heirachy in Enterprise Manager. Underneath each server is a collection of databases. Each database has collections of objects. Tables, Stored Procedures and Views all exist in collections under a database.<br />
Here is an example of some code that would loop through the tables collection to return the name of each table.<br />
<br />
'Assuming, we have set up our connection.<br />
<br />
Dim objDB As Database<br />
Set objDB = objDMO.Databases("northwind")<br />
<br />
Dim oTable As Table<br />
For Each oTable In objDB.Tables<br />
MsgBox oTable.Name <br />
Next<br />
<br />
<pre>'Assuming, we have set up our connection.
Dim objDB As Database
Set objDB = objDMO.Databases("northwind")
Dim oTable As Table
Set oTable = objDB.Tables("employees")
'Assuming we have a text box control named text1
Text1.Text = oTable.Script()
declare @objDMO int
declare @objDatabase int
declare @resultCode int
declare @dbname varchar(200)
declare @tablename varchar(200)
declare @cmd varchar(300)
declare @temp varchar(8000)
Set @dbname = 'PUBS'
Set @tablename = 'Authors'
EXEC @resultcode = sp_OACreate 'SQLDMO.SQLServer', @objDMO OUT
if @resultcode = 0
print 'Created Object'
Exec @resultcode = sp_OASetProperty @objDMO, 'loginsecure', 'true'
EXEC @resultcode = sp_OAMethod @objDMO, 'Connect', NULL, '(local)'
if @resultcode = 0
print 'connected'
Set @cmd = 'databases("' + @dbname + '").tables("' + @tablename + '").script'
Exec @resultcode = sp_OAMethod @objDMO, @cmd , @temp OUTPUT, 4
print @temp
EXEC @resultcode = sp_OADestroy @objDMO
if @resultcode = 0
Print 'destroyed object'</pre>
<br />
<h4>
Conclusion</h4>
This has been a very brief introduction to SQL-DMO. It is a topic that a huge book could be written on so I have barely scratched the surface. The examples here are very basic and not very useful in themselves but give you an idea as to what can be achieved. I urge you to experiment with DMO and see what you can do with it. If you have any questions, post them in the forums here and I am sure you will get some help.</div>
Lasanthahttp://www.blogger.com/profile/17007166390115409126noreply@blogger.com0tag:blogger.com,1999:blog-6077242124709045756.post-13449924326190092152011-10-16T00:30:00.000-07:002014-08-26T19:05:58.695-07:00Send mail with VB.NET + Gmail<div dir="ltr" style="text-align: left;" trbidi="on">
<style>
pre {
background-color: #FAFAFA;
font-size: 9pt;
line-height: 125%;
margin: 1em 0 0;
overflow: auto;
padding: 0.99em;
word-wrap: break-word;
}
code, pre {
color: #007000;
font-family: monospace;
}
.tag {
color: #000088;
}
.pln {
color: #000000;
}
.com {
color: #880000;
}
.atn {
color: #660066;
}
.pun {
color: #666600;
}
.atv {
color: #008800;
}
.kwd {
color: #000088;
}
.typ {
color: #660066;
}
.str {
color: #008800;
}
</style>
<div dir="ltr" style="text-align: left;" trbidi="on">
Here is a post how to send Email using VB.NET including your Gmail Account
<br />
<pre><a name='more'></a>
</pre>
<pre>Imports System.Net.Mail
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim mail As New MailMessage
Dim smtpServer As New SmtpClient
smtpServer.Credentials = New Net.NetworkCredential("hellolasantha@gmail.com", "")
smtpServer.Port = 587
smtpServer.Host = "smtp.gmail.com"
smtpServer.EnableSsl = True
mail = New MailMessage
mail.From = New MailAddress("sebder@gmail.com", "Web Developers", System.Text.Encoding.UTF8)
mail.Subject = "Testing"
mail.Body = "Body"
mail.To.Add("receiver@gmail.com")
Try
smtpServer.Send(mail)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
</pre>
</div>
</div>
Lasanthahttp://www.blogger.com/profile/17007166390115409126noreply@blogger.com1tag:blogger.com,1999:blog-6077242124709045756.post-6263083819537650052011-10-16T00:29:00.000-07:002013-02-02T07:37:12.437-08:00Codeignitor Simple Example<div dir="ltr" style="text-align: left;" trbidi="on">
<b><span class="Apple-style-span" style="font-family: verdana;">How To Remove index.php</span></b><br />
<div>
<b><span class="Apple-style-span" style="font-family: verdana;">How To use CSS,Javascript & etc in your site</span></b></div>
<div>
<br /></div>
<div>
Before Start</div>
<div>
<br />
<a name='more'></a><br /></div>
<div>
my directory structure is like following</div>
<div>
D:\XAMPP\htdocs\CI\</div>
<div>
<br /></div>
<div>
if you try </div>
<div>
<br /></div>
<div>
http://localhost/ci/</div>
<div>
<br /></div>
<div>
this will redirect you to default welcome Message</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
Follow this</div>
<div>
<br /></div>
<div>
open Notepad</div>
<div>
type following</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
File>Save As</div>
</div>
Lasanthahttp://www.blogger.com/profile/17007166390115409126noreply@blogger.com0tag:blogger.com,1999:blog-6077242124709045756.post-18679658187591631332011-10-10T23:15:00.000-07:002012-06-03T22:21:09.313-07:00Google Chart API perfect way to visualize data in your web site<style>
pre {
background-color: #FAFAFA;
font-size: 9pt;
line-height: 125%;
margin: 1em 0 0;
overflow: auto;
padding: 0.99em;
word-wrap: break-word;
}
code, pre {
color: #007000;
font-family: monospace;
}
.tag {
color: #000088;
}
.pln {
color: #000000;
}
.com {
color: #880000;
}
.atn {
color: #660066;
}
.pun {
color: #666600;
}
.atv {
color: #008800;
}
.kwd {
color: #000088;
}
.typ {
color: #660066;
}
.str {
color: #008800;
}
</style>
<div dir="ltr" style="text-align: left;" trbidi="on">
Google Chart API perfect way to visualize data in your web site<br />
<br />
JavaScript classes. Many Chat Types. Easily Customizable. Highly Interactive with events.
Charts are rendered using HTML5/SVG technology to provide cross-browser
compatibility (including VML for older IE versions) and cross platform
portability to iPhones, iPads and Android. No plugins are needed.<br />
<br />
Perfect right?<br />
<br />
You should identify there are two types of charts are provided by google.<br />
<br />
1. http://code.google.com/apis/chart/<br />
Google chart tools are powerful, simple to use, and free. Try out our rich gallery of interactive charts and data tools. <br />
<br />
2. http://code.google.com/apis/chart/image/<br />
The Google Chart API lets you dynamically
generate charts with a URL string. You can embed these charts on your web page,
or download the image for local or offline use. <br />
<br />
<br />
Its not hard to build up a chart using google. Its easy. Google documentation gives you enough details to customize your chart.<br />
<br />
Sample example<br />
<br />
<pre class="prettyprint lang-html"><span class="tag"><html></span><span class="pln"><br> </span><span class="tag"><head></span><span class="pln"><br> </span><span class="com"><!--Load the AJAX API--></span><span class="pln"><br> </span><span class="tag"><script</span><span class="pln"> </span><span class="atn">type</span><span class="pun">=</span><span class="atv">"text/javascript"</span><span class="pln"> </span><span class="atn">src</span><span class="pun">=</span><span class="atv">"https://www.google.com/jsapi"</span><span class="tag">></script></span><span class="pln"><br> </span><span class="tag"><script</span><span class="pln"> </span><span class="atn">type</span><span class="pun">=</span><span class="atv">"text/javascript"</span><span class="tag">></span><span class="pln"><br> <br> </span><span class="com">// Load the Visualization API and the piechart package.</span><span class="pln"><br> google</span><span class="pun">.</span><span class="pln">load</span><span class="pun">(</span><span class="str">'visualization'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'1.0'</span><span class="pun">,</span><span class="pln"> </span><span class="pun">{</span><span class="str">'packages'</span><span class="pun">:[</span><span class="str">'corechart'</span><span class="pun">]});</span><span class="pln"><br> <br> </span><span class="com">// Set a callback to run when the Google Visualization API is loaded.</span><span class="pln"><br> google</span><span class="pun">.</span><span class="pln">setOnLoadCallback</span><span class="pun">(</span><span class="pln">drawChart</span><span class="pun">);</span><span class="pln"><br> <br> </span><span class="com">// Callback that creates and populates a data table, </span><span class="pln"><br> </span><span class="com">// instantiates the pie chart, passes in the data and</span><span class="pln"><br> </span><span class="com">// draws it.</span><span class="pln"><br> </span><span class="kwd">function</span><span class="pln"> drawChart</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln"><br><br> </span><span class="com">// Create the data table.</span><span class="pln"><br> </span><span class="kwd">var</span><span class="pln"> data </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> google</span><span class="pun">.</span><span class="pln">visualization</span><span class="pun">.</span><span class="typ">DataTable</span><span class="pun">();</span><span class="pln"><br> data</span><span class="pun">.</span><span class="pln">addColumn</span><span class="pun">(</span><span class="str">'string'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'Topping'</span><span class="pun">);</span><span class="pln"><br> data</span><span class="pun">.</span><span class="pln">addColumn</span><span class="pun">(</span><span class="str">'number'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'Slices'</span><span class="pun">);</span><span class="pln"><br> data</span><span class="pun">.</span><span class="pln">addRows</span><span class="pun">([</span><span class="pln"><br> </span><span class="pun">[</span><span class="str">'Mushrooms'</span><span class="pun">,</span><span class="pln"> </span><span class="lit">3</span><span class="pun">],</span><span class="pln"><br> </span><span class="pun">[</span><span class="str">'Onions'</span><span class="pun">,</span><span class="pln"> </span><span class="lit">1</span><span class="pun">],</span><span class="pln"><br> </span><span class="pun">[</span><span class="str">'Olives'</span><span class="pun">,</span><span class="pln"> </span><span class="lit">1</span><span class="pun">],</span><span class="pln"> <br> </span><span class="pun">[</span><span class="str">'Zucchini'</span><span class="pun">,</span><span class="pln"> </span><span class="lit">1</span><span class="pun">],</span><span class="pln"><br> </span><span class="pun">[</span><span class="str">'Pepperoni'</span><span class="pun">,</span><span class="pln"> </span><span class="lit">2</span><span class="pun">]</span><span class="pln"><br> </span><span class="pun">]);</span><span class="pln"><br><br> </span><span class="com">// Set chart options</span><span class="pln"><br> </span><span class="kwd">var</span><span class="pln"> options </span><span class="pun">=</span><span class="pln"> </span><span class="pun">{</span><span class="str">'title'</span><span class="pun">:</span><span class="str">'How Much Pizza I Ate Last Night'</span><span class="pun">,</span><span class="pln"><br> </span><span class="str">'width'</span><span class="pun">:</span><span class="lit">400</span><span class="pun">,</span><span class="pln"><br> </span><span class="str">'height'</span><span class="pun">:</span><span class="lit">300</span><span class="pun">};</span><span class="pln"><br><br> </span><span class="com">// Instantiate and draw our chart, passing in some options.</span><span class="pln"><br> </span><span class="kwd">var</span><span class="pln"> chart </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> google</span><span class="pun">.</span><span class="pln">visualization</span><span class="pun">.</span><span class="typ">PieChart</span><span class="pun">(</span><span class="pln">document</span><span class="pun">.</span><span class="pln">getElementById</span><span class="pun">(</span><span class="str">'chart_div'</span><span class="pun">));</span><span class="pln"><br> chart</span><span class="pun">.</span><span class="pln">draw</span><span class="pun">(</span><span class="pln">data</span><span class="pun">,</span><span class="pln"> options</span><span class="pun">);</span><span class="pln"><br> </span><span class="pun">}</span><span class="pln"><br> </span><span class="tag"></script></span><span class="pln"><br> </span><span class="tag"></head></span><span class="pln"><br><br> </span><span class="tag"><body></span><span class="pln"><br> </span><span class="com"><!--Div that will hold the pie chart--></span><span class="pln"><br> </span><span class="tag"><div</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"chart_div"</span><span class="tag">></div></span><span class="pln"><br> </span><span class="tag"></body></span><span class="pln"><br></span><span class="tag"></html></span></pre>
<br/>
Have fun make you chart
Lasanthahttp://www.blogger.com/profile/17007166390115409126noreply@blogger.com0tag:blogger.com,1999:blog-6077242124709045756.post-60493408310710672252011-09-18T22:31:00.000-07:002012-06-03T22:21:54.545-07:00Instalation of xdebug on Linux and Work with Eclipse (Ubuntu 11.04)<div dir="ltr" style="text-align: left;" trbidi="on">
The Xdebug extension helps you debugging your script by providing a lot of<br />
valuable debug information.(http://pecl.php.net/package/xdebug)<br />
<br />
<b>Installation of xdebug</b><br />
<br />
Open up ur terminal and do below<br />
<br />
<span class="Apple-style-span" style="color: blue;">sudo pecl install xdebug</span><br />
<br />
Output of terminal display like below<br />
<br />
<span class="Apple-style-span" style="color: #93c47d;">Build process completed successfully</span><br />
<span class="Apple-style-span" style="color: #93c47d;">Installing '/usr/lib/php5/20090626+lfs/xdebug.so'</span><br />
<span class="Apple-style-span" style="color: #93c47d;">install ok: channel://pecl.php.net/xdebug-2.1.2</span><br />
<span class="Apple-style-span" style="color: #93c47d;">configuration option "php_ini" is not set to php.ini location</span><br />
<span class="Apple-style-span" style="color: #93c47d;">You should add "extension=xdebug.so" to php.ini</span><br />
<br />
editing the php.ini<br />
<br />
<span class="Apple-style-span" style="color: blue;">sudo gedit /etc/php5/apache2/php.ini</span><br />
<br />
append below line to php.ini<br />
You can find xdebug.so from when you install pecl. (Output message in terminal)<br />
<br />
<span class="Apple-style-span" style="color: #0b5394;">zend_extension=/usr/lib/php5/20090626+lfs/xdebug.so</span><br />
<span class="Apple-style-span" style="color: #0b5394;">xdebug.remote_enable=1</span><br />
<br />
<br />
<b>eclipse configuration</b><br />
<br />
Debug Configuration (Run>Debug Configuration)<br />
<br />
Set Server Debugger to XDebug (not Zend Debugger)<br />
<br />
Start Debugging</div>
Lasanthahttp://www.blogger.com/profile/17007166390115409126noreply@blogger.com0tag:blogger.com,1999:blog-6077242124709045756.post-65366930808171245312011-04-07T21:21:00.000-07:002012-06-03T22:26:04.509-07:00Expire Session When the Browser Close [Codeigniter]<div dir="ltr" style="text-align: left;" trbidi="on">
I wanted user to log again to the site whenever they close the browser. i searched everywhere and i found the easiest way.<br />
<div>
<span class="Apple-style-span" style="font-family: monospace; font-size: 13px;"><b><br /></b></span></div>
<div>
<span class="Apple-style-span" style="font-family: monospace; font-size: 13px;"><span class="Apple-style-span"><b>application/config/config.php</b></span></span></div>
<div>
<span class="Apple-style-span" style="font-family: monospace; font-size: 13px;"><span class="Apple-style-span"><b><br /></b></span></span></div>
<div>
<span class="Apple-style-span" style="font-family: monospace; font-size: 13px;"><span class="Apple-style-span"><b><span class="Apple-style-span" style="border-spacing: 1px; color: yellow; font-family: Georgia, serif; font-size: medium; font-weight: normal;"><strong style="background-color: white !important;">sess_expire_on_close = TRUE</strong></span></b></span></span></div>
<div>
<span class="Apple-style-span" style="font-family: monospace; font-size: 13px;"><span class="Apple-style-span"><b><span class="Apple-style-span" style="border-spacing: 1px; color: yellow; font-family: Georgia, serif; font-size: medium; font-weight: normal;"><strong style="background-color: white;"><br /></strong></span></b></span></span></div>
<div>
<span class="Apple-style-span" style="font-family: monospace; font-size: 13px;"><span class="Apple-style-span"><b><span class="Apple-style-span" style="border-spacing: 1px; color: yellow; font-family: Georgia, serif; font-size: medium; font-weight: normal;"><strong style="background-color: white;"><br /></strong></span></b></span></span></div>
<div>
<span class="Apple-style-span" style="font-family: monospace; font-size: 13px;"><span class="Apple-style-span"><b><span class="Apple-style-span" style="border-spacing: 1px; color: yellow; font-family: Georgia, serif; font-size: medium; font-weight: normal;"><strong style="background-color: white;">Easy</strong></span></b></span></span></div>
<div>
<h2>
Session Preferences</h2>
You'll find the following Session related preferences in your file:<br />
<table border="0" cellpadding="0" cellspacing="1" class="tableborder" style="width: 100%;"> <tbody>
<tr> <th>Preference</th> <th>Default</th> <th>Options</th> <th>Description</th> </tr>
<tr> <td class="td"><strong>sess_cookie_name</strong></td> <td class="td">ci_session</td> <td class="td">None</td> <td class="td">The name you want the session cookie saved as.</td> </tr>
<tr> <td class="td"><strong>sess_expiration</strong></td> <td class="td">7200</td> <td class="td">None</td> <td class="td">The number of seconds you would like the session to last. The default value is 2 hours (7200 seconds). If you would like a non-expiring session set the value to zero: 0</td> </tr>
<tr> <td class="td"><strong>sess_expire_on_close</strong></td> <td class="td">FALSE</td> <td class="td">TRUE/FALSE (boolean)</td> <td class="td">Whether to cause the session to expire automatically when the browser window is closed.</td> </tr>
<tr> <td class="td"><strong>sess_encrypt_cookie</strong></td> <td class="td">FALSE</td> <td class="td">TRUE/FALSE (boolean)</td> <td class="td">Whether to encrypt the session data.</td> </tr>
<tr> <td class="td"><strong>sess_use_database</strong></td> <td class="td">FALSE</td> <td class="td">TRUE/FALSE (boolean)</td> <td class="td">Whether to save the session data to a database. You must create the table before enabling this option.</td> </tr>
<tr> <td class="td"><strong>sess_table_name</strong></td> <td class="td">ci_sessions</td> <td class="td">Any valid SQL table name</td> <td class="td">The name of the session database table.</td> </tr>
<tr> <td class="td"><strong>sess_time_to_update</strong></td> <td class="td">300</td> <td class="td">Time in seconds</td> <td class="td">This options controls how often the session class will regenerate itself and create a new session id.</td> </tr>
<tr> <td class="td"><strong>sess_match_ip</strong></td> <td class="td">FALSE</td> <td class="td">TRUE/FALSE (boolean)</td> <td class="td">Whether to match the user's IP address when reading the session data. Note that some ISPs dynamically changes the IP, so if you want a non-expiring session you will likely set this to FALSE.</td> </tr>
<tr> <td class="td"><strong>sess_match_useragent</strong></td> <td class="td">TRUE</td> <td class="td">TRUE/FALSE (boolean)</td> <td class="td">Whether to match the User Agent when reading the session data.</td></tr>
</tbody></table>
</div>
</div>
Lasanthahttp://www.blogger.com/profile/17007166390115409126noreply@blogger.com3tag:blogger.com,1999:blog-6077242124709045756.post-86875848650722476922011-04-05T23:36:00.000-07:002012-06-03T22:26:25.519-07:00Date Difference in PHPThere is a easy method for find date difference in php. <div><br /></div><div>But this method didn't work after i hosted my files. </div><div><br /></div><div>So i came up with following. it is generating difference in days. but you can use other calculations for generate Months, years. This is a simple method.</div><div><br /></div><div style="color:green; font-size:11px;">$from = date("Y-m-d",strtotime('2011-04-01'));<br /><br />$to= date("Y-m-d",strtotime('2011-04-06'));<br /><br />$diff = strtotime($from )-strtotime($to);<br /><br />echo floor($diff / (60*60*24));</div><div><span class="Apple-style-span"><br /></span></div><div><span class="Apple-style-span">60*60*24 = Generate Days (</span><span class="Apple-style-span" style="color: rgb(0, 0, 187); font-family: Consolas, 'Andale Mono WT', 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 14px; ">86400</span><span class="Apple-style-span" style="font-family: georgia; font-size: small; ">)</span></div><div><span class="Apple-style-span" style="font-family: georgia; font-size: small; "><br /></span></div><div><span class="Apple-style-span"><span class="Apple-style-span" style="font-family: Consolas, 'Andale Mono WT', 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 14px; "><span class="string" style="color: rgb(221, 0, 0); background-color: transparent; ">"year" </span><span class="keyword" style="color: rgb(0, 119, 0); background-color: transparent; ">= </span><span class="default" style="color: rgb(0, 0, 187); background-color: transparent; ">29030400</span><span class="keyword" style="color: rgb(0, 119, 0); background-color: transparent; ">, </span><br /><br /><span class="comment" style="color: rgb(255, 128, 0); background-color: transparent; ">// seconds in a year (12 months)<br /></span><span class="string" style="color: rgb(221, 0, 0); background-color: transparent; ">"month" </span><span class="keyword" style="color: rgb(0, 119, 0); background-color: transparent; ">= </span><span class="default" style="color: rgb(0, 0, 187); background-color: transparent; ">2419200</span><span class="keyword" style="color: rgb(0, 119, 0); background-color: transparent; ">, </span><span class="comment" style="color: rgb(255, 128, 0); background-color: transparent; ">// seconds in a month (4 weeks)<br /></span><span class="string" style="color: rgb(221, 0, 0); background-color: transparent; ">"week" </span><span class="keyword" style="color: rgb(0, 119, 0); background-color: transparent; ">= </span><span class="default" style="color: rgb(0, 0, 187); background-color: transparent; ">604800</span><span class="keyword" style="color: rgb(0, 119, 0); background-color: transparent; ">, </span><span class="comment" style="color: rgb(255, 128, 0); background-color: transparent; ">// seconds in a week (7 days)<br /></span><span class="string" style="color: rgb(221, 0, 0); background-color: transparent; ">"day" </span><span class="keyword" style="color: rgb(0, 119, 0); background-color: transparent; ">= </span><span class="default" style="color: rgb(0, 0, 187); background-color: transparent; ">86400</span><span class="keyword" style="color: rgb(0, 119, 0); background-color: transparent; ">, </span><span class="comment" style="color: rgb(255, 128, 0); background-color: transparent; ">// seconds in a day (24 hours)<br /></span><span class="string" style="color: rgb(221, 0, 0); background-color: transparent; ">"hour" </span><span class="keyword" style="color: rgb(0, 119, 0); background-color: transparent; ">= </span><span class="default" style="color: rgb(0, 0, 187); background-color: transparent; ">3600</span><span class="keyword" style="color: rgb(0, 119, 0); background-color: transparent; ">, </span><span class="comment" style="color: rgb(255, 128, 0); background-color: transparent; ">// seconds in an hour (60 minutes)<br /></span><span class="string" style="color: rgb(221, 0, 0); background-color: transparent; ">"minute" </span><span class="keyword" style="color: rgb(0, 119, 0); background-color: transparent; ">= </span><span class="default" style="color: rgb(0, 0, 187); background-color: transparent; ">60</span><span class="keyword" style="color: rgb(0, 119, 0); background-color: transparent; ">, </span><span class="comment" style="color: rgb(255, 128, 0); background-color: transparent; ">// seconds in a minute (60 seconds)<br /></span><span class="string" style="color: rgb(221, 0, 0); background-color: transparent; ">"second" </span><span class="keyword" style="color: rgb(0, 119, 0); background-color: transparent; ">= </span><span class="default" style="color: rgb(0, 0, 187); background-color: transparent; ">1 </span><span class="comment" style="color: rgb(255, 128, 0); background-color: transparent; ">// 1 second</span></span></span></div><div><span class="Apple-style-span"><br /></span></div><div><span class="Apple-style-span"><br /></span></div>Lasanthahttp://www.blogger.com/profile/17007166390115409126noreply@blogger.com1tag:blogger.com,1999:blog-6077242124709045756.post-76546964113965588262011-04-02T07:13:00.001-07:002012-06-03T22:27:25.957-07:00Codeigniter Email Sending Using GMAILI searched this and got it. Worked fine. Only problem was below code line.<br /><br />$this->email->set_newline("\r\n");<br /><br />If you miss it code wont work<br /><br />$config = array(<br /> 'protocol' => 'smtp',<br /> 'smtp_host'=>'ssl://smtp.gmail.com',<br /> 'smtp_port' => 465,<br /> 'smtp_user'=>'username@gmail.com',<br /> 'smtp_pass'=>'password',<br /> 'mailtype' => 'html',<br /> 'charset'=> 'iso-8859-1', <br /> ); <br /> <br /> $this->load->library('email',$config);<br /> $this->email->from('user@gmail.com', 'Your Name'); <br /> $this->email->to('rec1@yahoo.com,rec2@gmail.com'); <br /> $this->email->subject('Email Test');<br /> $this->email->message('Testing the email class.'); <br /> $this->email->set_newline("\r\n");<br /> $this->email->send();<br /> <br /> echo $this->email->print_debugger();<br /><br />Simple as thatLasanthahttp://www.blogger.com/profile/17007166390115409126noreply@blogger.com1