Happy Programmer’s Day! 🙂
Get Twitter Status with JSON
13 08 2010$url = 'http://twitter.com/statuses/user_timeline/phoenixblue.json?count=10';
$url_content= file_get_contents($url,0,NULL,NULL);
$statuses = json_decode($url_content);
//var_dump($statuses);
echo $statuses[0]->text;
Comments : Leave a Comment »
Categories : JSON, PHP
Delete all Orders
2 08 2010Magento version 1.4.1.1
In Database,
SET FOREIGN_KEY_CHECKS = 1;
DELETE FROM sales_flat_order;
DELETE FROM sales_flat_quote;
DELETE FROM eav_entity_store;
Comments : Leave a Comment »
Categories : Magento, SQL
Reset Auto-Increment
2 08 2010Mighty useful for deleting test data!
ALTER TABLE table_name AUTO_INCREMENT = 1;
Comments : Leave a Comment »
Categories : SQL
CSS Rotation
1 08 2010Safari/Chrome
-webkit-transform: rotate(90deg);
Firefox
-moz-transform: rotate(90deg);
IE
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=1);
Comments : Leave a Comment »
Categories : CSS
Truncate Whole Words
1 08 2010function trunc($phrase, $max_words)
{
$phrase_array = explode(' ',$phrase);
if(count($phrase_array) > $max_words && $max_words > 0) {
$phrase = implode(' ',array_slice($phrase_array, 0, $max_words)).'...' ;
}
return $phrase;
}
Comments : Leave a Comment »
Categories : PHP
Get Twitter Statuses With curl()
1 08 2010function get_twitter_status() {
$status_list = array();
$c = curl_init();
curl_setopt($c, CURLOPT_URL, "http://twitter.com/statuses/user_timeline/phoenixblue.xml?count=10");
// count = number of statuses to grab
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($c, CURLOPT_CONNECTTIMEOUT, 20);
curl_setopt($c, CURLOPT_TIMEOUT,5);
$src = curl_exec($c);
$xmlList = new SimpleXMLElement($src);
foreach($xmlList->status as $xml) {
$text = (string)$xml->text;
$status_list[] = $text;
}
if(count($status_list) $status_list[] = $xmlList->error;
return $status_list;
}
Comments : Leave a Comment »
Categories : PHP
Problems With Magento Installation
1 08 2010Problem 1. Installing MCrypt on Mac
Mac OS X comes with pre-installed PHP which needs to be switched on and most likely updated to the latest version of PHP which is simple enough however installing MCrypt is a major pain. After spending 2 hours on this, I think the best thing to do is to use MAMP instead. Comes with Apache, PHP and MySQL.. SWEET!!!
Problem 2. Can’t log into admin
So Magento is installed on the localhost and now I can’t log into admin..
There are lots of workaround like changing the Varien.php file if you google this however they didn’t work for me so..
Please uninstall and make sure you reinstall Magento on http://127.0.0.1 instead of http://localhost/
Comments : Leave a Comment »
Categories : Error, Mac, Magento
Escape special characters in SQL statement
1 08 2010mysql_real_escape_string(string,connection)
$user = mysql_real_escape_string($user);
$pwd = mysql_real_escape_string($pwd);
$sql = "SELECT * FROM users WHERE user='" . $user . "' AND password='" . $pwd . "'"
Comments : Leave a Comment »
Categories : SQL
Change Last Modified Header
1 08 2010At the top of the file in php tags:
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
Comments : Leave a Comment »
Categories : PHP