Skip to content

Instantly share code, notes, and snippets.

@leavlzi
leavlzi / changeMyAlibabaTitle.js
Last active December 4, 2020 14:34
Change My Alibaba Page Title
// ==UserScript==
// @name Change My Alibaba Page Title
// @namespace http://tampermonkey.net/
// @version 0.5
// @updateURL https://gist.githubusercontent.com/leavlzi/de515ac17871a822755c7bb85277210d/raw/4d481334360d354358cbb4f2af5af3788ef533d1/changeMyAlibabaTitle.js
// @downloadURL https://gist.githubusercontent.com/leavlzi/de515ac17871a822755c7bb85277210d/raw/4d481334360d354358cbb4f2af5af3788ef533d1/changeMyAlibabaTitle.js
// @description Change Alibaba title!
// @author Moming
// @match https://*.alibaba.com/*
// @grant none
#Below code will work even if you don't know the exact sheet_names in the excel file. You can try this:
import pandas as pd
xls = pd.ExcelFile('myexcel.xls')
out_df = pd.DataFrame()
for sheet in xls.sheet_names:
df = pd.read_excel('myexcel.xls', sheet_name=sheet)
@leavlzi
leavlzi / CheckFileExistbyPathlib.py
Last active November 1, 2019 19:19
How to check if a file exists use new Pathlib
from pathlib import Path
fname = Path("c:\\test\\abc.txt")
print(fname.exists()) # true
print(fname.is_file()) # true
print(fname.is_dir()) # false
/*-------------------------------------------
Remove wpautop only for custom post types
-------------------------------------------*/
function wpc_remove_autop_for_posttype( $content )
{
'newsletter' === get_post_type() && remove_filter( 'the_content', 'wpautop' );
return $content;
}
@leavlzi
leavlzi / functions.php
Created October 21, 2017 16:00
To remove a class of the body_class function you have to do that
add_filter( 'body_class', function( $classes ) {
foreach($classes as $key => $class) {
if( $class == "class-to-remove" ){
unset($classes[$key]);
}
}
return $classes;
}, 1000);
@leavlzi
leavlzi / functions.php
Created October 6, 2017 18:37
Automatically add Alt Tag to WordPress Image Uploads
<?php
/*
Automatically add Alt Tag to WordPress Image Uploads
/* ------------------------------------ */
add_action( 'add_attachment', 'ced_add_image_meta_data' );
function ced_add_image_meta_data( $attachment_ID ) {
@leavlzi
leavlzi / functions.php
Last active October 24, 2018 01:59
Wordpress function add_meta_box() Sample https://9iphp.com/opensystem/wordpress/769.html
<?php
$new_meta_boxes =
array(
"description" => array(
"name" => "description",
"std" => "",
"title" => "description:"),
"keywords" => array(
"name" => "keywords",
/* Add responsive container to embeds
/* ------------------------------------ */
function alx_embed_html( $html ) {
return '<div class="video-container">' . $html . '</div>';
}
add_filter( 'embed_oembed_html', 'alx_embed_html', 10, 3 );
add_filter( 'video_embed_html', 'alx_embed_html' ); // Jetpack
Use WordPress default function to get next and previous post title with permalink something like this:
<?php // FOR PREVIOUS POST
$prev_post = get_previous_post();
$id = $prev_post->ID ;
$permalink = get_permalink( $id );
?>
<?php // FOR NEXT POST
$next_post = get_next_post();
$nid = $next_post->ID ;
@leavlzi
leavlzi / wp-menu-no-ul-li.php
Created September 30, 2017 18:32
Delete Wordpress Menu div & ul & li
<?php echo str_replace("</li>", "", ereg_replace("<li[^>]*>", "", wp_nav_menu(array('container' => 'false', 'items_wrap' => '%3$s','theme_location' => 'nav', 'echo' => false)) )); ?>