Skip to content

Instantly share code, notes, and snippets.

@hiephm
hiephm / pQuery.js
Created March 9, 2016 09:40 — forked from niyazpk/pQuery.js
Add or update query string parameter
// Add / Update a key-value pair in the URL query parameters
function updateUrlParameter(uri, key, value) {
// remove the hash part before operating on the uri
var i = uri.indexOf('#');
var hash = i === -1 ? '' : uri.substr(i);
uri = i === -1 ? uri : uri.substr(0, i);
var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
var separator = uri.indexOf('?') !== -1 ? "&" : "?";
if (uri.match(re)) {
@hiephm
hiephm / magento1_oauth_testing.md
Last active October 23, 2024 09:45
How to do OAuth 1.0 manually (Magento 1)

How to do OAuth 1.0 manually (Magento 1)

0. Pre-requisites:

  • consumer_key: d208adaf663a85029c33f55ce73d2705
  • consumer_secrect: 9faba5ec4c19aa68ca96511201b20f69
  • Initiate url: http://domain.com/oauth/initiate
  • Authorize url: http://domain.com/admin/oauth_authorize
  • Token request url: http://domain.com/oauth/token
  • Callback url (for dumping returned oauth_token and oauth_verifier): http://domain.com/callback.php
@hiephm
hiephm / di.xml
Last active February 5, 2016 02:37
<!-- To generate Interceptor, declare a plugin for virtualType, but plugin won't be executed with this alone -->
<type name="\Magento\LayeredNavigation\Block\Navigation\Category">
<plugin name="my-plugin" type="\MyVendor\MyModule\Plugin\BlockNavigation"/>
</type>
<!-- For plugin to be actually executed, declare the same plugin for actual class -->
<type name="\Magento\LayeredNavigation\Block\Navigation">
<plugin name="my-plugin" type="\MyVendor\MyModule\Plugin\BlockNavigation"/>
</type>