Skip to content

Instantly share code, notes, and snippets.

@erichuang2015
erichuang2015 / crud.py
Created August 22, 2018 06:25 — forked from alessandrocucci/crud.py
MySQL CRUD Operations using Python
#!/usr/bin/env python
'''
MySQL CRUD (Create Retrieve Update Delete) Operations using Python
'''
__author__ = "Alessandro Cucci"
__license__ = "MIT"
__version__ = "0.0.1"
__email__ = "alessandro.cucci@gmail.com"
__status__ = "Development"
$(function() {
// Filter Ajax Load More
var alm_is_animating = false;
$('#alm-filter-nav li').eq(0).addClass('active'); // Set the initial button active state
// Nav btn click event
$('#alm-filter-nav li a').on('click', function(e){
e.preventDefault();
var el = $(this); // Our selected element
@erichuang2015
erichuang2015 / wc_ajax_add_to_cart.php
Created October 14, 2018 00:58
Woocommerce Ajax Add To Cart Button
<?php
//AJAX ADD TO CART BUTTON
$product_id = 143;
if( !my_custom_cart_contains( $product_id ) ) {
?>
<button class="my-custom-add-to-cart-button" data-product-id="<?php echo $product_id; ?>">add to cart</button>
<?php
} else {
?>
@erichuang2015
erichuang2015 / hide-admin-notices.php
Created February 11, 2019 00:24 — forked from digisavvy/hide-admin-notices.php
hide admin notices in WordPress.
add_action('admin_enqueue_scripts', 'ds_admin_theme_style');
add_action('login_enqueue_scripts', 'ds_admin_theme_style');
function ds_admin_theme_style() {
if (!current_user_can( 'manage_options' )) {
echo '<style>.update-nag, .updated, .error, .is-dismissible { display: none; }</style>';
}
}
@erichuang2015
erichuang2015 / json_indent.php
Created August 25, 2019 08:01 — forked from dgoguerra/json_indent.php
json prettify in PHP
/**
* Indents a flat JSON string to make it more human-readable.
*
* http://www.daveperrett.com/articles/2008/03/11/format-json-with-php/
*/
function json_indent($json)
{
$result = '';
$pos = 0;
$strLen = strlen($json);