Skip to content

Instantly share code, notes, and snippets.

View cuonghuynh's full-sized avatar
🏠
Working from home

Cuong Huynh cuonghuynh

🏠
Working from home
View GitHub Profile
@cuonghuynh
cuonghuynh / gist:feeb742c2ea01d11397d9c86d4fd4343
Created August 30, 2018 05:40
A VirtualBox machine with the name already exists
$ vboxmanage list vms
"old-vm" {c700b8b6-b766-4638-871b-736b44b7db18}
$ vim .vagrant/machines/default/virtualbox/id
--> copy old-vm-id past here
@cuonghuynh
cuonghuynh / gist:0c3459370e89d46c7b0cc2843b8e1f23
Created August 30, 2018 02:21
Downgrade Node to specific version
⟩ npm install -g n
⟩ n [your_version]
@cuonghuynh
cuonghuynh / gist:1a7960d3385eb1451cd2785c92c074a6
Created August 28, 2018 07:23
Fix Warning: ftp_put(): Command denied by firewall
Enable passive mode: ftp_pasv($conn, true);
* Place it after ftp_login()
@cuonghuynh
cuonghuynh / function.get-product.liquid
Last active August 19, 2018 19:28
Find product by handle in the given collections (fix reach maximum number of unique handle on function product_all[handle])
{% assign return = false %}
{% if pass_product_handle and pass_collections %}
{% for collection in pass_collections %}
{% for product in collection.products %}
{% if pass_product_handle == product.handle %}
{% assign return = product %}
{% endif %}
{% endfor %}
{% endfor %}
{% endif %}
@cuonghuynh
cuonghuynh / Vagrantfile
Created June 12, 2018 15:00
Vagrant file configuration of Scotchbox with sync multiple folders
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "scotch/box"
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.hostname = "scotchbox"
#config.vm.synced_folder ".", "/var/www", :mount_options => ["dmode=777", "fmode=666"]
@cuonghuynh
cuonghuynh / collection.liquid
Created May 31, 2018 18:29
Shopify - Scroll infinity collection page
{% paginate collection.products by 20 %}
<!-- the top of your collections.liquid -->
<!-- START PRODUCTS -->
{% for product in collection.products %}
<!-- START PRODUCT {{ forloop.index | plus:paginate.current_offset }} -->
<div class="product" id="product-{{ forloop.index | plus:paginate.current_offset }}">
{% include 'product' with product %}
</div>
<!-- END PRODUCT {{ forloop.index | plus:paginate.current_offset }} -->
@cuonghuynh
cuonghuynh / function.array.get-value.liquid
Last active May 31, 2018 16:42
Shopify - create function to reuse
{% comment %}
This function will find value responding to the given key
params:
- keys: array
- values: array
- key: mixed
- default: mixed // the default value if not found
return:
- value: mixed
{% comment %}
@cuonghuynh
cuonghuynh / common.liquid
Created May 31, 2018 15:58
Shopify - define array in liquid
# link https://raisedbyturtles.org/shopify-associative-arrays
<% assign itemsArray = "item1#item2" | split: '#' %>
<% assign sizesArray = "small#large" | split: '#' %>
<% assign colorsArray = "blue#green" | split: '#' %>
<% for item in itemsArray %>
<% if item == 'item1' %>
{{ colorsArray[forloop.index0] }}
<% endif %>
@cuonghuynh
cuonghuynh / collection_filter.liquid
Created May 31, 2018 15:44
Shopify - tag links
# Link https://help.shopify.com/themes/liquid/objects/current-tags?
<ul>
{% for tag in collection.all_tags %}
{% if current_tags contains tag %}
<li class="active">{{ tag | link_to_remove_tag: tag }}</li>
{% else %}
<li>{{ tag | link_to_add_tag: tag }}</li>
{% endif %}
{% endfor %}
@cuonghuynh
cuonghuynh / collection_filter.liquid
Last active May 31, 2018 15:42
Shopify - add a class to link_add_to_tag in
# Link https://ecommerce.shopify.com/c/ecommerce-design/t/add-a-class-to-link_to_add_tag-255792
{{ tag | link_to_add_tag: tag | replace: 'title=', 'class="new" title=' }}