Sep 20, 2018

Swift4 - php hash_hmac to iOS hash

While working on APIs this could be one problem when the docs only written in php. :(

While looking the solution I found CryptoSwift which could help and solve my problem. Please check CryptoSwift on how to install.

Hear's same php to iOS conversion code.
PHP hash_hmac:
$hash = hash_hmac( 'SHA512', "YOUR_STRING_DATA_TO_HASH_HERE", 'YOUR_SECRET_KEY' // SHARED KEY ); print ("HMAC:" . $hash);

XCODE hmac
let yourData: Array = Array("YOUR_STRING_DATA_TO_HASH_HERE".utf8)
do{
   let myhmac = try HMAC(key: "YOUR_SECRET_KEY", variant: .sha512)

    // great your found your hash
   let iosHash = try myhmac.authenticate(password).toHexString()
   print ("HMAC:", iosHash)
}catch let err as NSError{
    
}


PHP hash:
$hash = hash( 'SHA512', "YOUR_STRING_DATA_TO_HASH_HERE" ); print ("HMAC:" . $hash);

XCODE Hash
print ("Hash:", "YOUR_STRING_DATA_TO_HASH_HERE".sha512())


NOTED: Be sure you import the CryptoSwift in your swift code.

Thanks for passing by.

Aug 9, 2018

Xcode - Rendering HTML code to your UILabel View

Im have been search on the net but most I see was still on Objective-c Language. Here what I discovered solution.
let htmlText = "<ul><li><b>Heloo</b></li><li>World</li></ul><hr>
<ol><li>Im <b>Heloo</b></li><li>World</li></ol>"
if let htmlData = htmlText.data(using: String.Encoding.unicode) {
  do {

    let attributedText = try NSAttributedString(data: htmlData,
    options: [
NSAttributedString.DocumentReadingOptionKey.documentType: NSAttributedString.DocumentType.html
],
    documentAttributes: nil)

    //Setting htmltext to uilable
    detailLabel.attributedText = attributedText

  } catch let e as NSError {
    //setting plane text to uilable cause of err
    detailLabel.text = htmlText
    print("Couldn't translate \(htmlText): \(e.localizedDescription) ")
  }
}

Update:
* Some reported that it will affect the scroll ability of table view. I never tested yet since I didn't work on tableview for this purpose.

Oct 9, 2017

Magento2 - Unittest with Object manager

As much as possible avoid using object manager to create object on magento if your going to create unittest on it. Use the Factory instead but in some case some plugins(Unirgy) love the object manager. Then when you override there class you will getting headache on creating unittest.

One of the error you will encounter was
"Expectation failed for method name is equal to <string:create> when invoked zero or more times" this  happen  you call create method  multiple times.
Sample:

 /** @var \Winz\Sales\Api\Data\OrderInvoiceResultInterface */
$orderInvoiceResultInterface = $this->getMockBuilder('Winz\Sales\Api\Data\OrderInvoiceResultInterface')
    ->disableOriginalConstructor()              
    ->setMethods(['setOrder', 'setInvoice', 'getOrder', 'getInvoice', ])
    ->getMock();      
$orderInvoiceResult = $objectManagerInterface
    ->expects($this->any())
    ->method('create')
    ->with('Storm\Sales\Api\Data\OrderInvoiceResultInterface')
    ->willReturn($orderInvoiceResultInterface);
/** @var \Winz\Sales\Api\Data\OrderResultInterface */
$orderResultInterface = $this->getMockBuilder('Winz\Sales\Api\Data\OrderResultInterface')
    ->disableOriginalConstructor()
    ->setMethods(['setId', 'setNo', 'getId', 'getNo'])
    ->getMock();      
$orderResult = $objectManagerInterface
    ->expects($this->once())
    ->method('create') 
  ->with('Winz\Sales\Api\Data\OrderResultInterface')
    ->willReturn($orderResultInterface);

Fixed of the above code.
$orderResultInterface = $this->getMockBuilder('Storm\Sales\Api\Data\OrderResultInterface')
    ->disableOriginalConstructor()
    ->getMock();
$orderInvoiceResultInterface = $this->getMockBuilder('Winz\Sales\Api\Data\OrderInvoiceResultInterface')
    ->disableOriginalConstructor()              
    ->setMethods(['setOrder', 'setInvoice', 'getOrder', 'getInvoice', ])
    ->getMock();      
$objectManagerInterface
    ->expects($this->any())
    ->method('create')
    ->withConsecutive(
            ['Storm\Sales\Api\Data\OrderResultInterface'],
            ['Storm\Sales\Api\Data\OrderInvoiceResultInterface']
    )
    ->willReturnOnConsecutiveCalls(
            $this->returnValue($orderResultInterface),
            $this->returnValue($orderInvoiceResultInterface)
    );


Sep 26, 2017

Magento2 - List of Validation Rules

List of form validation rules
jQuery rules:
required,
remote,
email,
url,
date,
dateISO,
number,
digits,
creditcard,
equalTo,
maxlength,
minlength,
rangelength,
range,
max,
min
Magento rules:
max-words
min-words
range-words
letters-with-basic-punc
alphanumeric
letters-only
no-whitespace
zip-range
integer
vinUS
dateITA
dateNL
time
time12h
phoneUS
phoneUK
mobileUK
stripped-min-length
email2
url2
credit-card-types
ipv4
ipv6
pattern
allow-container-className
validate-no-html-tags
validate-select
validate-no-empty
validate-alphanum-with-spaces
validate-data
validate-street
validate-phoneStrict
validate-phoneLax
validate-fax
validate-email
validate-emailSender
validate-password
validate-admin-password
validate-customer-password
validate-url
validate-clean-url
validate-xml-identifier
validate-ssn
validate-zip-us
validate-date-au
validate-currency-dollar
validate-not-negative-number
validate-zero-or-greater
validate-greater-than-zero
validate-css-length
validate-number
required-number
validate-number-range
validate-digits
validate-digits-range
validate-range
validate-alpha
validate-code
validate-alphanum
validate-date
validate-date-range
validate-cpassword
validate-identifier
validate-zip-international
validate-one-required
validate-state
required-file
validate-ajax-error
validate-optional-datetime
validate-required-datetime
validate-one-required-by-name
less-than-equals-to
greater-than-equals-to
validate-emails
validate-cc-type-select
validate-cc-number
validate-cc-type
validate-cc-exp
validate-cc-cvn
validate-cc-ukss
validate-length
required-entry
not-negative-amount
validate-per-page-value-list
validate-per-page-value
validate-new-password
required-if-not-specified
required-if-all-sku-empty-and-file-not-loaded
required-if-specified
required-number-if-specified
datetime-validation
required-text-swatch-entry
required-visual-swatch-entry
required-dropdown-attribute-entry
Validate-item-quantity
validate-grouped-qty
validate-one-checkbox-required-by-name
validate-date-between
validate-dob

Aug 15, 2017

Magento 2 - Best way to mass update attribute value of a product.

Here my code.
$productIds = [1,2,34]; // List of product Ids
$productAttribute = \Magento\Framework\App\ObjectManager::getInstance()
            ->create('Magento\Catalog\Model\ResourceModel\Product\Action');
$productAttribute->updateAttributes($productIds, 
['name' => 'New Name for all product'], // List of attribute you want to update NVP
$storeId
);

Idea gets from best-way-to-update-products-attribute-value

Jul 9, 2017

Laravel5 -> Creating/Understanding Custom Validation.

Main goal to create our own validation and set message associated to our validation.

*

Implented the validation rule

$RULES = ['name' => 'required|myrule'];
Vaidator::make($ARRAY_DATA, $RULES);

*

Create custom rule. In app/Providers/AppServiceProvider.php add code below on boot function.

//  Create  your custome valitor
Validator::extend('myrule', function($attr $value, $params) {
    return ((rand(10,100)%2) == 0); // Random return failed/Pass
},
"validation.myrule"
);

// Create the  message rule message.
Validator::replacer('myrule', function($msg, $attr, $rule, $params) {
    return trans($message, ['attribute'=> $attribute]);
});

*

Create the rule message. Add entry on resources/lang/en/validation.php.


return [

'myrule' => 'Your :attribute got error.',

'custom' => [
  //  Your also add here, to override the message above for the specific file.
  // This not need unless you want some validation on specific field.
  'fieldname' => [
     'rulename' => ' This just sample custom my rule message',
   ],

  'name' => [
     'myrule' => 'My custom :attribute message override.',
   ]

]
];

Jun 29, 2017

Magento2 - Resetting admin password.

Reseting password could get 3 possible way.

1. Run command in your server console.

MAGENTO_DIR/bin/magento admin:user:create \
--admin-user="ADMINUSERNAME" \
--admin-password="NEWPASSWORD" \
--admin-email="admin@example.com" \
--admin-firstname="Admin" --admin-lastname="Admin"

2. If you dont have access to the server, you could try updating via your database server.

UPDATE admin_user 
SET password = CONCAT(SHA2('xxxxxxxYourNewPassword', 256), ':xxxxxxx:1') 
WHERE username = 'admin';
NOTE: xxxxxx character sequence is a cryptographic salt.
it is saved in app\etc\env.php file
<?php
return array (
  ...
  'crypt' => 
  array (
    'key' => '525701df74e6cba74d5e9a1bb3d935ad', //cryptographic salt
  ),
  ...

3. Use the Forgot Password.

May 31, 2017

Laravel5 - Working on multiple DB.

Some reasons you need multiple DB when you making test migration on current working application.
Like my case, you are currently working on postgresql which the old DB in in mysql. Which tester the current posgre DB. I cant made that DB as my migration destination. This I why I need multiple DB configuration.

Here simple thing I did.

* Configure database setting(config/database.php) to defined mutiple DB.
return [
    'default' => env('DB_CONNECTION', 'pgsql'),
    'fetch' => PDO::FETCH_ASSOC, 
    'connections' => [
        'pgsql' => [
            'driver' => 'pgsql',
            'host' => env('DB_HOST'),
            'database' => env('DB_DATABASE'),
            'username' => env('DB_USERNAME'),
            'password' => env('DB_PASSWORD'),
            'charset'  => env('DB_CHARSET', 'utf8'),
            'prefix'   => env('DB_PREFIX', ''),
            'schema'   => env('DB_SCHEMA', 'core'),
        ],
        
        /*
         * START -
         * Migration Tesd DB
         */
        'migration' => [
            // My Postgre DB Destination
            'driver' => 'pgsql',
            'host' => 'localhost'
            'database' => 'dest_db',
            'username' => 'myuser,
            'password' => 'MyPaswordd',
            'charset'  => env('DB_CHARSET', 'utf8'),
            'prefix'   => env('DB_PREFIX', ''),
            'schema'   => env('DB_SCHEMA', 'core'),
        ],
        'mysql' => [
            // Source Mysql DB Data.
            'driver'    => 'mysql',
            'host'      => '192.168.101.17',
            'port'      => 3306,
            'database'  => 'src_db',
            'username'  => 'myuser',
            'password'  => 'mypassword',
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
            //'timezone'  => env('DB_TIMEZONE', '+00:00'),
            'strict'    => env('DB_STRICT_MODE', false),
        ],
    ],
];


While Working on migration script. I learn to use the Console feature of laravel.

$users = DB::connection('mysql')
    ->select('SELECT * FROM users '
        . 'limit 10' // For testing I put limit
    );

foreach($users as $user){
    // Create as object since "setConnection" none static
    $myuser = new \App\Model\App\Users();
    // Store the user to PSQL.
    // Assume the old and new table are same field names
    $myuser->setConnection('migration')
            ->store($user);

}

Feb 22, 2017

Laravel5 - How to log sql query?

Simple way, try to add code below on you route.

\Event::listen('Illuminate\Database\Events\QueryExecuted', function ($query) {
    \Log::debug($query->sql);
    //var_dump($query->bindings);
    //var_dump($query->time);
});


Working on 5.3

Aug 4, 2016

Laravel5 - AWS DynamoDB as session storage.

This post help you to create custom session service provider in your laravel application. Since, many application now a days uses one endpoint session storage for all their servers(A production application with multiple server behind a load balance).

In your laravel home project directory Issue artisan command.

php artisan make:provider MyDynamoDBServiceProvider

The command will generate file in app/Provider/MyDynamoDBServiceProvider.php
1. Add libraries below, just put just after use Illuminate\Support\ServiceProvider;

use Aws\DynamoDb\DynamoDbClient;
use Aws\DynamoDb\Session\SessionHandler;
use Aws\Credentials\Credentials;
use Session;
use Log;

2. Put code below in you register method.
Log:info(__METHOD__);
Session::extend('dynamodb', function ($app) {
    // Get a shortcut to config data            
    $cfg = $app['config']->get('session');
    
    // Do the real work of hooking up Dynamo as session handler
    $credential = new Credentials('YOUR_ACCESS_KEY', 'YOUR_SECRET_KEY');
    $dynamoDb = DynamoDbClient::factory([
        'region' => 'ap-northeast-1',
        'version' => '2012-08-10',
        'credentials' => $credential,
    ]);

    $sessionHandler = $dynamoDb->registerSessionHandler([
        'table_name'               => $cfg['table'],
        'hash_key'                 => 'key',
        'session_lifetime'         => 60 * $cfg['lifetime'],   // minutes to seconds
        'consistent_read'          => true,
        'locking_strategy'         => null,
        'automatic_gc'             => true,
        'gc_batch_size'            => 25,
        'max_lock_wait_time'       => 10,
        'min_lock_retry_microtime' => 10000,
        'max_lock_retry_microtime' => 50000
    ]);

    // Set the start of the session id to the cookie name - optional
    $sessionHandler->open('', $cfg['cookie']);
    
    return $sessionHandler;
    
});


3. Full Code will look like this.
<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Aws\DynamoDb\DynamoDbClient;
use Aws\DynamoDb\Session\SessionHandler;
use Aws\Credentials\Credentials;
use Session;
use Log;

class MyDynamoDBServiceProvider extends ServiceProvider{
    /**
     * Register the application services.
     *
     * @return void
     */
    public function register()
    {
        //
        Log:info(__METHOD__);
        Session::extend('dynamodb', function ($app) {
            // Get a shortcut to config data            
            $cfg = $app['config']->get('session');
            
            // Do the real work of hooking up Dynamo as session handler
            $credential = new Credentials('YOUR_ACCESS_KEY', 'YOUR_SECRET_KEY');
            $dynamoDb = DynamoDbClient::factory([
                'region' => 'ap-northeast-1',
                'version' => '2012-08-10',
                'credentials' => $credential,
            ]);

            $sessionHandler = $dynamoDb->registerSessionHandler([
                'table_name'               => $cfg['table'],
                'hash_key'                 => 'key',
                'session_lifetime'         => 60 * $cfg['lifetime'],
                'consistent_read'          => true,
                'locking_strategy'         => null,
                'automatic_gc'             => true,
                'gc_batch_size'            => 25,
                'max_lock_wait_time'       => 10,
                'min_lock_retry_microtime' => 10000,
                'max_lock_retry_microtime' => 50000
            ]);

            // Set the start of the session id to the cookie name - optional
            $sessionHandler->open('', $cfg['cookie']);
            
            return $sessionHandler;
            
        });
    }
}

4. Add it in you app provider config. Edit config/app.php and find providers section.

'providers' => [
.... some other provider list here

App\Providers\MyDynamoDBServiceProvider::class
];

NOTE: Please don't Use DynamoDBServiceProvider or DynamoServiceProvider name if you dont like some have ache.


Happy Reading



Reference:

To get more idea about AWS credential
Service Providers
Adding Custom Session Drivers

Jan 15, 2016

How to clean or remove scratched on your camera lens?

I really try to search lot of recommendation on the internet and some recommend to brush a cloth with toothpaste. However the toothpaste didn't work on my camera-lens instead the scratch(or blurdy section) get large. When that happen i've been too frustrated. So I stop it and dump my camera in one side and neva use again. Then one day I posted a question on one group of user with cameras with a question. "How do you remove scratches on on you camera lens?". One member answer me to use fine sandpaper and then in my think "WOW, I will going to do it worst". Just to give him some appreciation on his answer. I answer and I will try it.



Started that time, I already get have a key to search to verify the word of the man. Until one man response in a forum question on how to remove scratches on camera lens. The mean sad. "Camera lens is hard and not easy and Not easily to get scratch however if that happen use a fine sandpaper." With the mans word. I decide to try it on my camera. But before I did, I try first on my flash light lens for security that I may not doing the thing that could worst my camera lens. Since it the sandpaper work my flash light lens. it time to try on my camera lens.



Images before I sandpaper the lens.
SagadaOuting2015 - Trek to Bomod-ok Falls(Blurdy Pics)


Picture after I sandpapers my lens
FB: Micro shot testing

Dec 8, 2015

PHP - How to upgrade php 5.4 to php 5.5 on opensuse

Since, the current repository dont have 5.5.x version. try to check this one. php5


In my case, after I click "Direct Install" it lead me to this page and have content.





For us to have ability to upgrade PHP new repository. with the data highlighted on the screenshot.

http://download.opensuse.org/distribution/leap/42.1/repo/oss/

Jun 26, 2015

AWS - Extract protected API response data.

In most AWS API call you will get response model.

object(Guzzle\Service\Resource\Model)#97 (2) {
  ["structure":protected]=>
  NULL
  ["data":protected]=> Array(THE DATA YOU NEED TO ACCESS HERE)
}

Here my sample, call to describe the ec2 instance.

$result = $client->describeInstances();

var_dump($result); // Display the result in Guzzle\Service\Resource\Model

$response = $result->toArray(); // Convert the protected data, into array

// Display the intance IP information.
var_dump($response['Reservations'][0]['Instances'][0]['NetworkInterfaces'][0]['PrivateIpAddresses']);
Reference Stackoverflow.com

Mar 26, 2015

PHP - preg_match: Compilation failed: unknown option bit(s) set at offset 0

preg_match issue encounter after one admin update one service, unfortunately some common library need to update. Until those common library need by php thats why php also included on update.

After trying to figure out and googling the error, I found the preg_match uses prce as its library. One article on stackoverflow.com said he/she can able to work on php 4.x with prce 8.x. Since my prce still 7.8 I decide to update to 8.x and miracle happen(Issue was fixed).

NOTE: After you update your prce make sure to restart your apache.

Nov 6, 2014

TipS: Know the right pronunciation one a word - Power by google

Most the time I do google search on every english words that I don't understand, by typing on search box.
define:WORD
And most the time audio icon was displayed to get hear the how the word pronounce. But in some case you cant see the Audio Icon Button. Try this one.

https://ssl.gstatic.com/dictionary/static/sounds/de/0/WORD.mp3

Example:
https://ssl.gstatic.com/dictionary/static/sounds/de/0/gullible.mp3

NOTE: WORD must replace with word you looking for.

Sep 18, 2014

JS - Infinite scroll sample code.

// START OF INFINITE SCROLLING FUNCTION
var base_url = config.base_url;
var offset = 1;
var request_ajax = true;
var ajax_is_on = false;
var objHeight = $(window).height() - 50;
var last_scroll_top = 0;
    
    
var type = '0';
var csrftoken = $("meta[name='csrf-token']").attr('content');
var csrfname = $("meta[name='csrf-name']").attr('content');
$(window).scroll(function(event) {
  var st = $(this).scrollTop();
  if(st > last_scroll_top){
    if ($(window).scrollTop() + 100 > $(document).height() - $(window).height()) {
      if (request_ajax === true && ajax_is_on === false) {
        ajax_is_on = true; 
        $.ajax({
          url: base_url + 'category_more',
          data:{page_number:offset,id_cat:'459',type:type, parameters:'[]', csrfname : csrftoken},
          type: 'post',
          dataType: 'JSON',
          onLoading:jQuery(".loading").html('<img src="/assets/images/orange_loader.gif" />').show(),
          success: function(d) {
            if(d == "0"){
              ajax_is_on = true;
            }else{ 
              if(d.substring(0,5)  == ""){
                $($.parseHTML(d.trim())).appendTo($('#product_content'));
                ajax_is_on = true;
              }else{
                $($.parseHTML(d.trim())).appendTo($('#product_content'));
                ajax_is_on = false;
                offset += 1;   
              }
            }
            jQuery(".loading").fadeOut();    
          }
        });
      }
    }
  }
  last_scroll_top = st;
});
// END OF INFINITE SCROLLING FUNCTION

Sep 10, 2014

How to resize/increase tmpfs partition.

Increasing linux tmpfs partition have two way to do.

1. Modify you /etc/fstab and put the below. Setting below set the tmpfs size to 2GB
LABEL=/     /           ext4    defaults,noatime  1   1
tmpfs       /dev/shm    tmpfs   defaults        0   0
devpts      /dev/pts    devpts  gid=5,mode=620  0   0
sysfs       /sys        sysfs   defaults        0   0
proc        /proc       proc    defaults        0   0

Add size=2G inline to tmpfs besize defaults.
tmpfs       /dev/shm    tmpfs   defaults,size=2G        0   0
After you modify and save your changes, remount the partitions by issuing command below
# mount -o remount /dev/shm
And you done. Or try easier way below.




2. Or if you want the easier way, issue command below to set the tmpfs to 2GB.
sudo mount -o remount,size=2048M tmpfs /dev/shm
NOTE: The breakdown of doing this, this setting will revert after the system was rebooted, so I recommend to modify the /etc/fstab

Aug 28, 2014

How to download facebook video without special software?

Simple tutorial how to download facebook videos without install some special software for it.


Requirement:
* Chrome/Firefox Browser. For firefox you need to install FireBug.
* Internet connection and you must be logged-in(Common sense)
* Ability in read, interpret and imagine(I'm not a good writer)

Lets try this video as a sample. Mocha Gurl - Umay Boy Part 2




1. Inspect the element


2. Find embed tag for the specific video.


3. Get/copy the value of flashvars attribute. Value normally start params=





flashvars="params=%7B%22autoplay%22%3Afalse%2C%22autoplay_reason%22%3A%22unknown%22%2C%22autoplay_setting%22%3Anull%2C%22autorewind%22%3Atrue%2C%22click_to_snowlift%22%3Afalse%2C%22default_hd%22%3Afalse%2C%22dtsg%22%3A%22AQE4W0i3Toky%22%2C%22inline_player%22%3Afalse%2C%22lsd%22%3Anull%2C%22min_progress_update%22%3A300%2C%22pixel_ratio%22%3A1%2C%22player_origin%22%3A%22unknown%22%2C%22preload%22%3Atrue%2C%22source%22%3A%22permalink%22%2C%22start_index%22%3A0%2C%22start_muted%22%3Afalse%2C%22stream_type%22%3A%22stream%22%2C%22use_spotlight%22%3Afalse%2C%22video_data%22%3A%5B%7B%22hd_src%22%3Anull%2C%22is_hds%22%3Afalse%2C%22is_hls%22%3Afalse%2C%22index%22%3A0%2C%22rotation%22%3A0%2C%22sd_src%22%3A%22https%3A%5C%2F%5C%2Ffbcdn-video-e-a.akamaihd.net%5C%2Fhvideo-ak-xfp1%5C%2Fv%5C%2Ft42.1790-2%5C%2F10575106_10154494056700394_1631383348_n.mp4%3Foh%3Df51b7017371095edbdfb1e9218a586fb%26oe%3D53FF1B2E%26__gda__%3D1409229179_d647a9ac4f58d06db559a974aa5c5649%22%2C%22thumbnail_src%22%3A%22https%3A%5C%2F%5C%2Ffbcdn-vthumb-a.akamaihd.net%5C%2Fhvthumb-ak-xpf1%5C%2Fv%5C%2Ft15.0-10%5C%2F10604768_10154494056725394_10154494048125394_48484_1166_b.jpg%3Foh%3D2651e28da760bd2efcca19763e8caaf2%26oe%3D54719AD5%26__gda__%3D1416392706_e5a83bd683ae62999d79b20f37fddaa5%22%2C%22thumbnail_height%22%3A400%2C%22thumbnail_width%22%3A400%2C%22video_duration%22%3A71%2C%22video_id%22%3A%2210154494048125394%22%2C%22subtitles_src%22%3Anull%7D%5D%2C%22show_captions%22%3Afalse%2C%22persistent_volume%22%3Atrue%7D&width=720&height=720&user=100002615155849&log=no&div_id=id_53ff0136d3d4b5803062954&swf_id=swf_id_53ff0136d3d4b5803062954&browser=Chrome+35.0.1916.153&tracking_domain=https%3A%2F%2Fpixel.facebook.com&post_form_id=&string_table=https%3A%2F%2Fs-static.ak.facebook.com%2Fflash_strings.php%2Ft97862%2Fen_US"

4. The data is URL encoded and you need to decode in human readable data. For you to decode check URL Dencoder Tools


5. Find the sd_src, and copy the value. Important: You must understand JSON but, if you cant understand JSON just try to check and understand the image below.



In the image representation you can get the value.
https:\/\/fbcdn-video-e-a.akamaihd.net\/hvideo-ak-xfp1\/v\/t42.1790-2\/10575106_10154494056700394_1631383348_n.mp4?oh=f51b7017371095edbdfb1e9218a586fb&oe=53FF1B2E&__gda__=1409229179_d647a9ac4f58d06db559a974aa5c5649




6. Replace all \/ with a single slash only and your done.
https://fbcdn-video-e-a.akamaihd.net/hvideo-ak-xfp1/v/t42.1790-2/10575106_10154494056700394_1631383348_n.mp4?oh=f51b7017371095edbdfb1e9218a586fb&oe=53FF1B2E&__gda__=1409229179_d647a9ac4f58d06db559a974aa5c5649


7. Open the URL in your browser and press CTRL + S to save the video.
Instruction sample video can be download @Mocha Gurl - Umay Boy Part 2.

NOTE: If you encounter error message
An error occurred while processing your request.
Reference #50.3d34d417.1413363911.56c6c7
from the Download URL(w/c the .mp4) I provide try to follow the step #1 to #6. This reason is like security from facebook from creating automated call/request. I just notice that the parameters value after question-mark(?) is change every user login.

Cheers!!!!!!!!!!!
Hope you able to follow that simple instruction.

Jul 27, 2014

Magento - Customize your error page by store view.

In your magento home directory you can find file/folder structure.
Magento/
  errors/
     default/
        css/
        images/
        404.phtml
        503.phtml
        page.html
        report.phtml
     404.php
     503.php
     report.php
     processor.php
     local.xml

File description and uses.
404.php       -> I guess 404 page but seems not calls when i encounter.
503.php       -> Mostly for maintenance page(check your index.php)
report.php    -> this file calls when encounter un-handle exception.
processor.php -> Main class for error handling
local.xml     -> Error Handling configuration
    404.phtml -> 404 page template
    503.phtml -> Maintenance error handin template.
    page.html -> Main page or layout of the error excemption
    report.phtml -> Exception error template

Above info is just a head up about the file/folder structure and information. Now lets assume that you have store view with store code mobile(that simplify the store is for mobile). To create custom error for your store(Store front). Best way copy the default error and name it same to your store code.
$ cd MAGENTO_PATH_DIR/errors/
$ cp default mobile

Now is time for you to customize the mobile custom error page. For this to able to use, you have to modify MAGENTO/errors/local.xml

<config>
    <skin>default</skin> <!-- Change default in to mobile-->
    <!-- Some other setting below -->
</config>

Aside from modifying your local.xml. You can also access the site with a parameter skin and is your store code.
Example: http://localhost/magento?skin=mobile
or you can modify the MAGENTO/index.php and the code before below.
<?php
$_GET['skin']='mobile'; // Add aditional parameter on every request.
Mage::run($mageRunCode, $mageRunType);
?>

Jun 26, 2014

How to setup media wiki one lighttpd.

Assume the lighttpd already installed.

Add the configuration below for settings.

#fastcgi.server = (".php" =>("localhost" =>("host"=>"127.0.0.1","port"=>"1026","bin-path"=>"/usr/bin/php-cgi")))
url.rewrite-once = (
         "^/wiki/upload/(.+)" => "/wiki/upload/$1",
#        "^/wiki/config/(.+)" => "/wiki/config/$1",
         "^/wiki/skins/(.+)" => "$0",
#        "^/$" => "/wiki/index.php",
         "^/wiki/([^?]*)(?:\?(.*))?" => "/wiki/index.php?title=$1&$2"
)
#url.rewrite-if-not-file = (
#   "^/wiki/(mw-)?config/?" => "$0",
#    "^/wiki/([^?]*)(?:\?(.*))?" => "/w/index.php?title=$1&$2",
#    "^/wiki/([^?]*)" => "/w/index.php?title=$1",
#    "^/wiki$" => "/w/index.php", # to avoid 404 when the user types /wiki instead of /wiki/
#)
#url.redirect = ( "^/(?!w|wiki|robots\.txt|favicon\.ico)(.*)" => "/wiki/$1" )
#$HTTP["remoteip"] !~ "192.168.101.156" {
#    $HTTP["url"] =~ "^/wiki" {
#      url.access-deny = ( "" )
#    }
# }