Skip to content

Instantly share code, notes, and snippets.

View nhatnx's full-sized avatar

Nhat Nguyen nhatnx

  • Ho Chi Minh city, Vietnam
View GitHub Profile
@nhatnx
nhatnx / 0_reuse_code.js
Created October 20, 2015 05:04
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
@nhatnx
nhatnx / gist:eff8e47b29f4a1463b19
Created November 5, 2015 11:24 — forked from molotovbliss/gist:2562551
Magento Snippets

Magento Snippets

Set all categories to is_anchor 1

Find attribute_id

SELECT * FROM eav_attribute where attribute_code = 'is_anchor'

Update all of them with anchor_id from above (usually is ID 51)

UPDATE `catalog_category_entity_int` set value = 1 where attribute_id = 51
@nhatnx
nhatnx / Run in LOCAL terminal...
Created January 20, 2016 05:06 — forked from jswartwood/Run in LOCAL terminal...
Automatic Git deploys on Dreamhost
# Replace any brackets with real values
# Try to ssh in to DREAMHOST (ensure it no longer asks for a PW); you may want to restart Terminal
ssh [user]@[host]
cd ~
mkdir [mydomain_com].git
cd [mydomain_com].git
git init --bare
vi hooks/post-receive
# Enter the code from the "post-receive" file (in this gist); save + quit
<!-- for Module declaration -->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<!-- for Routers -->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<!-- for Layouts -->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<!-- for DI -->
/** http://getbootstrap.com.vn/examples/equal-height-columns/ **/
/** http://getbootstrap.com.vn/examples/equal-height-columns/equal-height-columns.css **/
/*
* Row with equal height columns
* --------------------------------------------------
*/
.row-eq-height {
display: -webkit-box;
display: -webkit-flex;
@nhatnx
nhatnx / 2011 Updated Clearfix.css
Created November 30, 2016 08:16
50 Useful CSS Snippets Every Designer Should Have From http://www.hongkiat.com/blog/css-snippets-for-designers/
.clearfix:before, .container:after { content: ""; display: table; }
.clearfix:after { clear: both; }
/* IE 6/7 */
.clearfix { zoom: 1; }
@nhatnx
nhatnx / get-records-with-max-value-for-each-group
Last active August 10, 2017 09:17
Get records with max value for each group of grouped SQL results
Person | Group | Age
---
Bob | 1 | 32
Jill | 1 | 34
Shawn| 1 | 42
Jake | 2 | 29
Paul | 2 | 36
Laura| 2 | 39
@nhatnx
nhatnx / scroll_to_element.js
Created August 10, 2017 09:20
jQuery animate scroll to an element
function scrollToElement($el) {
$('html, body').stop(true).animate({scrollTop: $el.offset().top}, 800);
}
@nhatnx
nhatnx / pmg-rewrite.php
Created October 11, 2017 05:37 — forked from chrisguitarguy/pmg-rewrite.php
WordPress rewrite tutorial
<?php
/*
Plugin Name: Rewrite Rule Tutorials
*/
add_action( 'init', 'pmg_rewrite_add_rewrites' );
function pmg_rewrite_add_rewrites()
{
add_rewrite_endpoint( 'json', EP_PERMALINK );
add_rewrite_rule(