Skip to content

Instantly share code, notes, and snippets.

View Jeff2Ma's full-sized avatar

Jeff Ma Jeff2Ma

View GitHub Profile
@Jeff2Ma
Jeff2Ma / Support PayPal GateWay in woocommerce.php
Last active August 28, 2022 12:07
Support PayPal GateWay in woocommerce【让woocommerce中文网关支持paypal并自动转换人民币美元转换】
<?php
//woocommerce中文网关支持paypal
// details at http://devework.com/support-paypal-gateway-in-woocommerce.html
//本函数解决的问题:贝宝不支持你的商铺货币。Gateway Disabled: PayPal does not support your store's currency.
add_filter( 'woocommerce_paypal_supported_currencies', 'enable_custom_currency' );
function enable_custom_currency($currency_array) {
$currency_array[] = 'CNY';
return $currency_array;
}
@Jeff2Ma
Jeff2Ma / woocommerce-featured-products.php
Last active August 26, 2021 00:29
woocommerce featured products
@Jeff2Ma
Jeff2Ma / alfred-json-format.sh
Created August 11, 2016 12:01
Alfred Script Filter JSON format
#
# Alfred Script Filter JSON format
#
# This example demonstrates all fields available for populating results.
#
# For an in-depth explanation, use the (?) help button to the bottom left.
#
cat << EOB
{"items": [
@Jeff2Ma
Jeff2Ma / change_default_price_html.php
Created July 18, 2014 14:51
change woocommerce defalut price html code
<?php
// DeveWork.com
//这是一个可以修改woocommerce_get_price_html 函数默认输出的html代码的例子,
//作用是调换新旧价格的位置
//感谢http://wordpress.stackexchange.com/questions/83367/how-to-edit-the-get-price-html-on-woocommerce
add_filter( 'woocommerce_get_price_html', 'dw_change_default_price_html', 100, 2 );
function dw_change_default_price_html( $price,$product ){
if ( $product->price > 0 ) {
@Jeff2Ma
Jeff2Ma / Dorm-network.scpt
Last active August 19, 2019 05:17
Automatic proxy configuration set pac file with applescript & shell script http://devework.com/automatic-proxy-configuration-pac-applescript.html
tell application "System Events"
tell network preferences
do shell script "scselect 'Dorm'"
do shell script "sudo networksetup -setairportpower AirPort on" user name "用户名" password "密码" with administrator privileges
do shell script "open /Applications/Shad**socksX.app" user name “用户名" password "密码" with administrator privileges
end tell
end tell
04f368761186cf61ac7bf2d48a6bf8d3892a6a928fb8593c449faf29135dbd871dd8dc4bfd4e6c02fd4303d7c53559da2a05a85a69c018ded4f1944cd1137a8a6b
@Jeff2Ma
Jeff2Ma / woocommerce-custom-override-checkout-fields.php
Created July 30, 2014 05:59
woocommerce-custom-override-checkout-fields
<?php
//以下用部分代码演示hook ‘woocommerce_checkout_fields’ 这个函数
//参考文章:http://devework.com/woocommerce-custom-override-checkout-fields.html
//删除结算页面上多余的表单元素(fields)
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
//unset($fields['order']['order_comments']);
unset( $fields['billing']['billing_country'] );
@Jeff2Ma
Jeff2Ma / gulpfile.js
Created December 29, 2016 11:16
Gulp reload on gulpfile.js change
// Gulp restart when gulpfile is changed
var spawn = require('child_process').spawn;
gulp.task('gulp-autoreload', function() {
// Store current process if any
var p;
gulp.watch('gulpfile.js', spawnChildren);
// Comment the line below if you start your server by yourslef anywhere else
spawnChildren();
@Jeff2Ma
Jeff2Ma / handlebar.md
Created May 18, 2016 13:00 — forked from aliencode/handlebar.md
handlebar 方法参考文档

handlebar 方法参考文档

介绍

Handlebars是JavaScript一个语义模板库,通过对view和data的分离来快速构建Web模板。它采用"Logic-less template"(无逻辑模版)的思路,在加载时被预编译,而不是到了客户端执行到代码时再去编译, 这样可以保证模板加载和运行的速度。Handlebars兼容Mustache,你可以在Handlebars中导入Mustache模板。

使用与安装

Handlebars的安装非常简单,你只需要从Github下载最新版本,你也可访问下面网址获取最新信息:http://handlebarsjs.com。 目前handlebars.js已经被许多项目广泛使用了,handlebars是一个纯JS库,因此你可以像使用其他JS脚本一样用script标签来包含handlebars.js

@Jeff2Ma
Jeff2Ma / surge.conf
Created December 5, 2015 09:57
自用的surge config 文件,代码已经删除账号信息
#surge.conf
[General]
skip-proxy = 192.168.0.0/16, 10.0.0.0/8, 172.0.0.0/8, localhost, *.local, e.crashlytics.com, *.jd.com
bypass-tun = 0.0.0.0/8, 1.0.0.0/9, 1.160.0.0/11, 1.192.0.0/11, 10.0.0.0/8, 14.0.0.0/11, 14.96.0.0/11, 14.128.0.0/11, 14.192.0.0/11, 27.0.0.0/10, 27.96.0.0/11, 27.128.0.0/9, 36.0.0.0/10, 36.96.0.0/11, 36.128.0.0/9, 39.0.0.0/11, 39.64.0.0/10, 39.128.0.0/10, 42.0.0.0/8, 43.224.0.0/11, 45.64.0.0/10, 47.64.0.0/10, 49.0.0.0/9, 49.128.0.0/11, 49.192.0.0/10, 54.192.0.0/11, 58.0.0.0/9, 58.128.0.0/11, 58.192.0.0/10, 59.32.0.0/11, 59.64.0.0/10, 59.128.0.0/9, 60.0.0.0/10, 60.160.0.0/11, 60.192.0.0/10, 61.0.0.0/10, 61.64.0.0/11, 61.128.0.0/10, 61.224.0.0/11, 100.64.0.0/10, 101.0.0.0/9, 101.128.0.0/11, 101.192.0.0/10, 103.0.0.0/10, 103.192.0.0/10, 106.0.0.0/9, 106.224.0.0/11, 110.0.0.0/7, 112.0.0.0/9, 112.128.0.0/11, 112.192.0.0/10, 113.0.0.0/9, 113.128.0.0/11, 113.192.0.0/10, 114.0.0.0/9, 114.128.0.0/11, 114.192.0.0/10, 115.0.0.0/8, 116.0.0.0/8, 117.0.0.0/9, 117.128.0.0/10, 118.0.0.0/11, 118.64.0.0/