Skip to content

Instantly share code, notes, and snippets.

View nvminhtu's full-sized avatar
🥰

Tu Nguyen nvminhtu

🥰
  • Virgo Studio
  • Ho Chi Minh
View GitHub Profile
@nvminhtu
nvminhtu / handling_multiple_github_accounts.md
Created January 6, 2023 03:56 — forked from Jonalogy/handling_multiple_github_accounts.md
Handling Multiple Github Accounts on MacOS

Handling Multiple Github Accounts on MacOS

The only way I've succeeded so far is to employ SSH.

Assuming you are new to this like me, first I'd like to share with you that your Mac has a SSH config file in a .ssh directory. The config file is where you draw relations of your SSH keys to each GitHub (or Bitbucket) account, and all your SSH keys generated are saved into .ssh directory by default. You can navigate to it by running cd ~/.ssh within your terminal, open the config file with any editor, and it should look something like this:

Host *
 AddKeysToAgent yes

> UseKeyChain yes

@nvminhtu
nvminhtu / editor-add-roles.php
Created June 24, 2022 10:42 — forked from chrisguitarguy/editor-add-roles.php
Allow users with the role editor to add users to WordPress -- but only subscribers.
<?php
/*
Plugin Name: Editors Add Users
Description: Allow editors to add user roles
Author: Christopher Davis
Author URI: http://www.christopherguitar.me
License: GPL2
*/
register_activation_hook( __FILE__, 'wpse42003_activation' );
@nvminhtu
nvminhtu / gist:e08a9480fa96fd748ca5d5b33ee9a36e
Created July 15, 2021 04:34 — forked from corsonr/gist:9152652
WooCommerce : add custom fields to product variations
<?php
//Display Fields
add_action( 'woocommerce_product_after_variable_attributes', 'variable_fields', 10, 3 );
//JS to add fields for new variations
add_action( 'woocommerce_product_after_variable_attributes_js', 'variable_fields_js' );
//Save variation fields
add_action( 'woocommerce_process_product_meta_variable', 'save_variable_fields', 10, 1 );
/**
<?php
/**
* Content template of a showreel
*/
?>
<div class="cd-product-list__item">
<?php
/* get ACF fields */
$studio = get_field('studio');
$agency = get_field('agency');
@nvminhtu
nvminhtu / ajax-filter-posts.js
Created April 29, 2021 07:24 — forked from nfsarmento/ajax-filter-posts.js
Ajax filters for CPT with custom taxonomy
(function($) {
'use strict';
jQuery(document).ready(function() {
//Load all posts
asr_ajax_get_postdata(-1);
$('.asr_texonomy').on('click',function(){
var term_id = $(this).attr('data_id');
@nvminhtu
nvminhtu / filter-post-thumbnail-id.php
Created April 7, 2021 09:10 — forked from westonruter/filter-post-thumbnail-id.php
How to filter the response for get_post_thumbnail_id()
<?php
/**
* How to filter the value that would be returned by get_post_thumbnail_id()
*/
add_filter( 'get_post_metadata', function ( $value, $post_id, $meta_key, $single ) {
// We want to pass the actual _thumbnail_id into the filter, so requires recursion
static $is_recursing = false;
// Only filter if we're not recursing and if it is a post thumbnail ID
@nvminhtu
nvminhtu / SSLXampp.md
Created April 2, 2021 07:55 — forked from nguyenanhtu/SSLXampp.md
Guide to configure SSL in XAMPP for Windows

How to test 'https' in XAMPP for localhost ? I will guide you

Menu

  • Create certificate
  • Config Apache to access https instead of http
  • Config mod rewrite to generate SSL url
  • Config Virtual host to test site

Step 1 : Create certificate

  • Go to your XAMPP installation directory (in my case it’s E:\xampp), figure out apache folder. In this, find & run batch file
@nvminhtu
nvminhtu / multi-git-win.md
Created March 22, 2021 09:24 — forked from rosswd/multi-git-win.md
Setting up a Github and Bitbucket account on the same computer on Mac OS. Now with a guide for Windows 10.

Setting up github and bitbucket on the same computer (Windows)

Guide for Windows

mix3d asked for some help using this guide with windows so here we go. This was tested with Windows 10. Run all commands in Git Bash once it's installed.

Github will be the main account and bitbucket the secondary.

Git for Windows

  • Download and install Git for Windows
    • In the installer, select everything but decide if you want a desktop icon (2nd step)
@nvminhtu
nvminhtu / _mixins.scss
Created September 28, 2020 10:39 — forked from garyharan/_mixins.scss
Useful scss mixins (rounded corners, gradients, text-field, button)
@mixin box-shadow($top, $left, $blur, $color, $inset: false) {
@if $inset {
-webkit-box-shadow:inset $top $left $blur $color;
-moz-box-shadow:inset $top $left $blur $color;
box-shadow:inset $top $left $blur $color;
} @else {
-webkit-box-shadow: $top $left $blur $color;
-moz-box-shadow: $top $left $blur $color;
box-shadow: $top $left $blur $color;
}
@nvminhtu
nvminhtu / woocommerce-simple-or-variable.php
Created July 31, 2020 09:40 — forked from patrickgilmour/woocommerce-simple-or-variable.php
WooCommerce conditional to test if a Product is Simple or Variable.
<?php
/**
* Is a WooCommerce Product Simple or Variable
*
* see http://wordpress.org/support/topic/condition-to-check-if-product-is-simple-or-variable
*/
if( $product->is_type( 'simple' ) ){
// a simple product