Skip to content

Instantly share code, notes, and snippets.

View ZhangChengX's full-sized avatar
🌸
I may be slow to respond.

Zhang Cheng ZhangChengX

🌸
I may be slow to respond.
View GitHub Profile
@ZhangChengX
ZhangChengX / python_url_matching_regex.py
Last active February 28, 2018 21:12
python url matching regex
"""
url matching regex
http://daringfireball.net/2010/07/improved_regex_for_matching_urls
"""
"""
The regex patterns in this gist are intended to match any URLs,
including "mailto:foo@example.com", "x-whatever://foo", etc. For a
pattern that attempts only to match web URLs (http, https), see:
@ZhangChengX
ZhangChengX / js_get_selected_text.js
Last active March 19, 2018 01:48
Getting highlighted/selected text.
// Selection object
//var selection = window.getSelection();
var selection = window.getSelection ? window.getSelection() : document.selection;
// Selected plain text
var selected_text = selection.toString();
// Range object
var range = selection.getRangeAt(0);
#!/usr/bin/env python
# coding: utf-8
# xlsx or csv to sql converter
# input file name will be the sql table name
# Usage: python3 xlsx_csv_to_sql_converter.py input_file.csv
import os
import sys
import csv
@ZhangChengX
ZhangChengX / functions.php
Created April 16, 2021 18:52 — forked from maddisondesigns/functions.php
WooCommerce Custom Fields for Simple & Variable Products
/*
* Add our Custom Fields to simple products
*/
function mytheme_woo_add_custom_fields() {
global $woocommerce, $post;
echo '<div class="options_group">';
// Text Field
// jquery shorthand
$(function(){
// jQuery methods go here...
});
// writing jQuery in WordPress
(function($) {
// Your jQuery code here, using the $
#!/usr/bin/env python
# -*- coding: utf-8 -*
# Reference
# https://github.com/zslwyuan/google-ngrams/blob/master/getngrams.py
from nltk.corpus import words
from ast import literal_eval
from tqdm import tqdm
import requests