^ ^

13 09 2010

Happy Programmer’s Day! 🙂

Advertisements




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;





Delete all Orders

2 08 2010

Magento 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;





Reset Auto-Increment

2 08 2010

Mighty useful for deleting test data!

ALTER TABLE table_name AUTO_INCREMENT = 1;





CSS Rotation

1 08 2010

Safari/Chrome
-webkit-transform: rotate(90deg);

Firefox
-moz-transform: rotate(90deg);

IE
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=1);





Truncate Whole Words

1 08 2010

function 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;
}





Get Twitter Statuses With curl()

1 08 2010

function 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;
}