Skip to content

Instantly share code, notes, and snippets.

View phamngsinh's full-sized avatar

Pham Ng Sinh phamngsinh

View GitHub Profile
@phamngsinh
phamngsinh / gist:9a49cd415c78aff22c629422fb617920
Created July 13, 2017 10:08 — forked from croxton/gist:4073583
Install xdebug 2.2.0 for AMPPS on OSX
Grab the 'PHP Remote Debugging Client' (the pre-complied xdebug binary for OSX) from here:
http://code.activestate.com/komodo/remotedebugging/
Unzip it, find the folder that corresponds to the version of PHP you want to install it for and copy the xdebug.so file from there into your php extensions folder in the relevant PHP version directory. E.g. for PHP 5.4:
/Applications/AMPSS/php-5.4/lib/extensions/ext/
Now open PHP.ini in a text editor:
/Applications/AMPSS/php-5.4/etc/php.ini
@phamngsinh
phamngsinh / gist:121f00edf54c3b202d3afcb74e5acf9f
Created May 30, 2017 01:53
This routine calculates the distance between two points
<?php
/*::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/
/*:: :*/
/*:: This routine calculates the distance between two points (given the :*/
/*:: latitude/longitude of those points). It is being used to calculate :*/
/*:: the distance between two locations using GeoDataSource(TM) Products :*/
/*:: :*/
/*:: Definitions: :*/
/*:: South latitudes are negative, east longitudes are positive :*/
@phamngsinh
phamngsinh / gist:348c4b3c4e1dc84e0b9976644202a1e1
Created May 29, 2017 08:52
Magento 2 - Create order using REST API
Get a single product
curl -g -X GET "$base_url/index.php/rest/V1/products/24-MB05/" \
-H "Authorization: Bearer $token"
Create cart
curl -g -X POST "$base_url/index.php/rest/V1/guest-carts/" \
-H "Authorization: Bearer $token"
Get Cart
curl -g -X GET "$base_url/index.php/rest/V1/guest-carts/56241bf6bc084cd7589426c8754fc9c5" \
-H "Authorization: Bearer $token"
Add Product To Cart
@phamngsinh
phamngsinh / gist:3a7c21a1cad15562607519fe698b71ff
Created May 29, 2017 07:53
Get Token Authentication For Customer Logged With Facebook & Twitter : Magento 2
/**
* {@inheritdoc}
*/
public function createCustomerAccessToken($username, $password)
{
$this->validatorHelper->validate($username, $password);
$this->getRequestThrottler()->throttle($username, RequestThrottler::USER_TYPE_CUSTOMER);
try {
$customerDataObject = $this->accountManagement->authenticate($username, $password);
} catch (\Exception $e) {
<?php
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Webapi\Model\Authorization;
use Magento\Authorization\Model\UserContextInterface;
use Magento\Integration\Model\Oauth\Token;
@phamngsinh
phamngsinh / gist:526ee2aee796400d89bc9ef7eebaf5f7
Created April 24, 2017 14:25
Disable Microsoft Autoupdate
$ defaults write /Users/username/Library/Preferences/com.microsoft.autoupdate2 WhenToCheck 0
$ defaults read /Users/username/Library/Preferences/com.microsoft.autoupdate2 WhenToCheck 0
@phamngsinh
phamngsinh / install-sample-magento
Created March 20, 2017 10:32
How to install sample data after magento setup ?
1 .Add dependencies to the composer.json:
composer require magento/module-bundle-sample-data:100.1.0 magento/module-widget-sample-data:100.1.0 magento/module-theme-sample-data:100.1.0 magento/module-catalog-sample-data:100.1.0 magento/module-customer-sample-data:100.1.0 magento/module-cms-sample-data:100.1.0 magento/module-catalog-rule-sample-data:100.1.0 magento/module-sales-rule-sample-data:100.1.0 magento/module-review-sample-data:100.1.0 magento/module-tax-sample-data:100.1.0 magento/module-sales-sample-data:100.1.0 magento/module-grouped-product-sample-data:100.1.0 magento/module-downloadable-sample-data:100.1.0 magento/module-msrp-sample-data:100.1.0 magento/module-configurable-sample-data:100.1.0 magento/module-product-links-sample-data:100.1.0 magento/module-wishlist-sample-data:100.1.0 magento/module-swatches-sample-data:100.1.0 magento/sample-data-media:100.1.0 magento/module-offline-shipping-sample-data:100.1.0 --no-update
2. Run:
composer update
3. Deploy sample data:
bin/magento sampledat
@phamngsinh
phamngsinh / mysql.txt
Created October 9, 2016 15:54
create admin from mysql in wordpress
INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`)
VALUES ('smagic39', MD5('pass123'), 'firstname lastname', 'email@example.com', '0');
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`)
VALUES (NULL, (Select max(id) FROM wp_users), 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`)
VALUES (NULL, (Select max(id) FROM wp_users), 'wp_user_level', '10');
@phamngsinh
phamngsinh / add-key-to-ssh
Created October 7, 2016 08:17
add key to ssh
step 1: eval `ssh-agent -s`
step 2: ssh-add path-to-key-file
@phamngsinh
phamngsinh / gitcheckout.md
Created October 2, 2016 15:21
How to clone a specific Git branch?