Skip to content

Instantly share code, notes, and snippets.

View nttan's full-sized avatar

Nguyen Tan nttan

View GitHub Profile
@nttan
nttan / add-checkout-form-key.sh
Created December 24, 2019 18:18 — forked from schmengler/add-checkout-form-key.sh
Magento SUPEE-9767 Checkout Form Key Theme Patch
find -L app/design/frontend -regex '.*\(shipping\|billing\|shipping_method\|payment\).phtml' -exec grep -L formkey {} \; \
| xargs sed -i 's/<\/form>/<?php echo $this->getBlockHtml("formkey") ?><\/form>/g'
find -L skin/frontend -name 'opcheckout.js' -exec grep -L form_key {} \; \
| xargs sed -i 's/if (elements\[i\].name=='\''payment\[method\]'\'') {/if (elements[i].name=='\''payment[method]'\'' || elements[i].name == '\''form_key'\'') {/g'
@nttan
nttan / optimg.sh
Created July 3, 2019 07:15 — forked from sergeylukin/optimg.sh
Shell script for JPGs and PNGs optimization
#!/usr/bin/env sh
#
# This script automates images optimization
# is mainly used by a developer who manually
# can execute it when adding new images to the
# project
#
# Download and compile following binaries:
#
# - [jpegtran](http://www.ijg.org/)
@nttan
nttan / or-example.php
Created July 27, 2018 02:49 — forked from Vinai/or-example.php
SearchCriteria OR Example for Magento 2
<?php
declare(strict_types = 1);
namespace Training5\VendorRepository\Controller\Test;
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Framework\Api\Filter;
use Magento\Framework\Api\FilterBuilder;
@nttan
nttan / gist:04c06dce2807a96a272e00089bfc7df8
Created May 17, 2018 06:21 — forked from bryhal/gist:4129042
MYSQL: Generate Calendar Table
DROP TABLE IF EXISTS time_dimension;
CREATE TABLE time_dimension (
id INTEGER PRIMARY KEY, -- year*10000+month*100+day
db_date DATE NOT NULL,
year INTEGER NOT NULL,
month INTEGER NOT NULL, -- 1 to 12
day INTEGER NOT NULL, -- 1 to 31
quarter INTEGER NOT NULL, -- 1 to 4
week INTEGER NOT NULL, -- 1 to 52/53
day_name VARCHAR(9) NOT NULL, -- 'Monday', 'Tuesday'...
@nttan
nttan / salesforce.js
Created October 19, 2015 04:41 — forked from mobyjames/salesforce.js
Squarespace Forms Integration for Salesforce
Y.namespace('Template').Salesforce = Class.create({
/*
baseUrl
oid
sqsFormSubmit
*/
initialize: function (config) {
this.config = config;
},
@nttan
nttan / 0_reuse_code.js
Last active August 29, 2015 14:13
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console