Skip to content

Instantly share code, notes, and snippets.

View alvinnguyen's full-sized avatar

Alvin Nguyen alvinnguyen

View GitHub Profile
@alvinnguyen
alvinnguyen / ec2-classic-networking-deprecation.md
Created July 11, 2022 10:47
Step by step on finding EC2-Classic Networking resource on AWS account
@alvinnguyen
alvinnguyen / magento2.postman_collection.json
Created February 8, 2018 02:34
Magento 2 REST API POSTman collection
{
"info": {
"name": "Magento Enterprise",
"_postman_id": "568abbbd-3033-0165-6f9e-748fc011684e",
"description": "",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "V1",
@alvinnguyen
alvinnguyen / selenium-php-webdriver-cheatsheet.md
Created June 8, 2017 06:29 — forked from aczietlow/selenium-php-webdriver-cheatsheet.md
Cheat sheet for using php webdriver (facebook/webdriver).

Webdriver PHP API workthough

  • Open a browser

    # start an instance of firefox with selenium-webdriver
    
    $browser_type = 'firefox'
    $host = 'http://localhost:4444/wd/hub'
    

$capabilities = array(\WebDriverCapabilityType::BROWSER_NAME => $browser_type);

@alvinnguyen
alvinnguyen / magento-delete-attribute-options.php
Last active March 27, 2017 05:55 — forked from jonathansayag/magento-delete-attribute-options.php
Magento PHP script to delete all values of an attribute
<?php
$attribute_code = 'fashion_colour';
$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', $attribute_code);
$options = $attribute->getSource()->getAllOptions();
$optionsDelete = array();
$optionsValue = array();
foreach($options as $option) {
if (in_array($option['label'], $optionsValue)) {
$optionsDelete['delete'][$option['value']] = true;
$optionsDelete['value'][$option['value']] = true;
@alvinnguyen
alvinnguyen / grab-all-product-attributes.sql
Created February 1, 2017 03:22 — forked from tegansnyder/grab-all-product-attributes.sql
Magento grab all product attributes for a SKU in direct SQL. "static" backend_type attributes are stored in catalog_product_entity
SELECT * FROM ( SELECT
ce.sku,
ea.attribute_id,
ea.attribute_code,
CASE ea.backend_type
WHEN 'varchar' THEN ce_varchar.value
WHEN 'int' THEN ce_int.value
WHEN 'text' THEN ce_text.value
WHEN 'decimal' THEN ce_decimal.value
WHEN 'datetime' THEN ce_datetime.value
@alvinnguyen
alvinnguyen / magento_copy_product_images.php
Created December 30, 2016 00:03 — forked from jreinke/magento_copy_product_images.php
Magento: copy images from one product to another
<?php
/**
* Copy all images from $productSrc to $productDest
*
* @param Mage_Catalog_Model_Product $productSrc
* @param Mage_Catalog_Model_Product $productDest
*/
public function copyProductImages(Mage_Catalog_Model_Product $productSrc, Mage_Catalog_Model_Product $productDest)
{
$images = array();
<?xml version="1.0"?>
<config>
<frontend>
<events>
<!--disable logs-->
<controller_action_predispatch>
<observers><log><type>disabled</type></log></observers>
</controller_action_predispatch>
<controller_action_postdispatch>
<observers><log><type>disabled</type></log></observers>
@alvinnguyen
alvinnguyen / 0_reuse_code.js
Created September 13, 2016 23:43
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
@alvinnguyen
alvinnguyen / mysql_replace.sql
Created September 9, 2016 00:44
How to replace value in mysql query
update core_config_data
set value = replace(value, 'intl.forever', 'oscarintl.forever')
where value like '%intl.forevernew%'; -- this is so the query doesn't spend time checking all other rows
@alvinnguyen
alvinnguyen / cli_debug.sh
Last active November 29, 2017 08:33
xdebug for PHP command line
#!/bin/bash
export XDEBUG_CONFIG="idekey=PHPSTORM" &&
export PHP_IDE_CONFIG="serverName=Unnamed" &&
php "$@"
Also put this into
/etc/php/5.6/fpm/conf.d/20-xdebug.ini
xdebug.remote_host=192.168.56.1