Jul 29, 2013

CSS - Understanding the unit for font size.

Normally the equivalent of the unit is listed below.
1em = 12pt = 16px = 100%.

However that the unit have same conversion value. There still a different behavior on the display of the content.

As explained in kyleschaeffer.com, using a percent(%) much more reliable to use. And he was also recommend to use % as unit to use in website designning. See more explanation in his topic here @kyleschaeffer.com

Jul 18, 2013

HTML: Special keywords for mobile site(SMS composer and Voice Call)

here some special keyword on phone. This is like mailto on your pc.

Compose an SMS to you mobile website

sms:12345678?body=Your default message
In some other devices some URI are also working. mms:, smsto: or mmsto:.


To call the mobile.

tel:09054633787

This was also use in mobile facebook..

Jul 17, 2013

Magento: Creating block and inject to you layout.

Here the simple code

// In your controller action
public function indexAction()
{
  //Get current layout state
  $this->loadLayout();
  $block = $this->getLayout()->createBlock(
    'Mage_Core_Block_Template',
    'my_block_name_here',
    array('template' => 'module/my_custumtemplate.phtml') 
  );

  // always to for surely the you block not invalid
  try{
    $this->getLayout()->getBlock('content')->append($block);
  }catch(Exception $e){
  }
  //Release layout stream... lol... sounds fancy
  $this->renderLayout();
}

Jul 11, 2013

How to download movie in ustream.tv?

For this tutorial, I will going use FHM 2013 stream.
FHM Stream or FHM Stream on ustream.tv

Requirement:
* You must have account to ustream.tv and must login.(I not sure if make with login coz I was login on the time I made this)

Step:

1. Visit FHM Stream on ustream.tv and check the html source code(Please use Inspect Element tool of you chrome browser). Point your mouse pointer on the nearest part of the Flash Stream for you to easy to find the code and Right Click your mouse then select Inspect Element(if you cant see option point in other place, maybe you are pointing to none html element, maybe image/Flash)


You must see this code this view, and you need to concatenate the value of data attribute in object element and value of params element with name flashvars



Base on the given information.
Object element of data attribute value
http://static-cdn1.ustream.tv/swf/live/viewer:196.swf?vrsl=c:507&ulbr=100
The value of params with the name of flashvars is
vid=35631517&locale=en_SG&sessionid=1744c589f98fb28e742091d2fc7768e7&userid=26125091&autoplay=true&enablejsapi=1&sv=6&ts=1373591555219

To concatenate you must put ampersand(&) in between the given data.
http://static-cdn1.ustream.tv/swf/live/viewer:196.swf?vrsl=c:507&ulbr=100&vid=35631517&locale=en_SG&sessionid=1744c589f98fb28e742091d2fc7768e7&userid=26125091&autoplay=true&enablejsapi=1&sv=6&ts=1373591555219

2. Visit the URL and copy the Status URL, see screen shot below


From the highlighhted data on the image, this is the URL which is what we need to download the content. Download FHM 100 Sexiest Woman 2013
http://upmv09.gblx.upmv.ustream.tv/0/1/35/35631/35631517/1_15153845_35631517.flv/tracking=6887ea_1_1_0_0&src=ro&per=EQIX.DE-CIX&hash=7d64&ri=3192&rs=57


NOTE:
Maybe the URL given is not working since I login by my account. So better check the by ur self.

UPDATE: The Exact url can be extract as.
Sample: http://upmv09.gblx.upmv.ustream.tv/0/1/35/35954/35954563/1_15153845_35954563.flv
Extract: http://upmv09.gblx.upmv.ustream.tv/0/1/35/{1ST_FIVE_DIG_OF_VID_ID}/{VIDEOID}/1_{CHANNEL_ID}_{VIDEOID}.flv

Jul 3, 2013

Magento: How to minified your html content?

I know its very bad idea to modify the core code, but sorry I don't have time to test override the class.


To do this you need to modify Mage_Core_Block_Template class and its fetchView method.

public function fetchView($fileName)
{
  // ***********
  // Some other code up
  // *********************

  // This is the in the bottom code
  if (Mage::app()->getStore()->getCode() == 'admin'){
     // Admin must not to minify since, there was lot on inline comment(//)
     // which generate javascript error.
     return $html;
  }else{
    // Instead of just returning the html data, you need to
    //  remove the  un-needed extra space and new lines.
    $html = preg_replace('/\s+/', ' ', trim($html)); // remove new line

    // Remove space on every start on a tag </script> <div> become </script> <div>
    $html = preg_replace('/ </', '<',$html); // For more compression only you can skip this line.

    return $html; 
  }


}







WARNING:

This is not applicable if you have javascript in your template will an inline comment double slash(//). Since the code become one line, whole javascript after the // become comment. I know you know that. Suggestion pleas use the group comment(/*** Your comment inside */) or move all you javascript in a js file. :)

Cheerr

Jul 2, 2013

Magento: core_file_storage' doesn't exist'

This kind of error mostly happen if you just copy a database and checkout the source that you team is working for..

So here the solution I found, create to tables manually.
core_directory_storage
CREATE TABLE `core_directory_storage` (
  `directory_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` VARCHAR(255) NOT NULL DEFAULT '',
  `path` VARCHAR(255) NOT NULL DEFAULT '',
  `upload_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `parent_id` INT(10) UNSIGNED NULL DEFAULT NULL,
  PRIMARY KEY (`directory_id`),
  UNIQUE INDEX `IDX_DIRECTORY_PATH` (`name`, `path`),
  INDEX `parent_id` (`parent_id`),
  CONSTRAINT `FK_DIRECTORY_PARENT_ID` FOREIGN KEY (`parent_id`) 
  REFERENCES `core_directory_storage` (`directory_id`) ON UPDATE     CASCADE ON DELETE CASCADE
)
COMMENT='Directory storage'
COLLATE='utf8_general_ci'
ENGINE=InnoDB
ROW_FORMAT=DEFAULT
core_file_storage
CREATE TABLE `core_file_storage` (
  `file_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `content` LONGBLOB NOT NULL,
  `upload_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `filename` VARCHAR(255) NOT NULL DEFAULT '',
  `directory_id` INT(10) UNSIGNED NULL DEFAULT NULL,
  `directory` VARCHAR(255) NULL DEFAULT NULL,
  PRIMARY KEY (`file_id`),
  UNIQUE INDEX `IDX_FILENAME` (`filename`, `directory`),
  INDEX `directory_id` (`directory_id`),
  CONSTRAINT `FK_FILE_DIRECTORY` FOREIGN KEY (`directory_id`) 
    REFERENCES `core_directory_storage` (`directory_id`) ON UPDATE CASCADE ON DELETE CASCADE
)
COMMENT='File storage'
COLLATE='utf8_general_ci'
ENGINE=InnoDB
ROW_FORMAT=DEFAULT