Skip to content

Instantly share code, notes, and snippets.

View trujunzhang's full-sized avatar

Trujun Zhang trujunzhang

View GitHub Profile
@trujunzhang
trujunzhang / gist:1a8509351cb184137e303db5fe9dae46
Created October 18, 2016 13:59 — forked from kloon/gist:4228021
WooCommerce variations custom field
//Display Fields
add_action( 'woocommerce_product_after_variable_attributes', 'variable_fields', 10, 2 );
//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', 'variable_fields_process', 10, 1 );
function variable_fields( $loop, $variation_data ) {
?>
<tr>
@trujunzhang
trujunzhang / invites.js
Created September 13, 2016 14:27 — forked from xavxyz/invites.js
var communityName = Settings.get('title','Telescope'),
emailSubject = 'You are invited to try '+communityName,
route = user ? Telescope.utils.getSigninUrl() : Telescope.utils.getSignupUrl(), // this the line I added
emailProperties = {
newUser : typeof user === 'undefined',
communityName : communityName,
actionLink : Telescope.utils.getSiteUrl() + route, // site url + route depending if the user already have an account or not
invitedBy : Users.getDisplayName(currentUser),
profileUrl : Users.getProfileUrl(currentUser)
};
@trujunzhang
trujunzhang / tornado-nginx-example.conf
Created September 4, 2016 15:30 — forked from didip/tornado-nginx-example.conf
Nginx config example for Tornado
worker_processes 2;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
use epoll;
}
@trujunzhang
trujunzhang / README.md
Created August 28, 2016 06:03 — forked from timothyandrew/README.md
Set up a seedbox (on DigitalOcean – Ubuntu) really quick

Introduction

  • This script lets you set up and use a temporary DigitalOcean droplet to download torrent files.
  • Once downloaded, they can be streamed down to your local machine.
  • This uses transmission-cli for the torrent client, and nginx to serve files.

Setup on Local Machine

  • This assumes that you have a DigitalOcean account and tugboat set up, as well as seedbox-setup.sh present in the current directory.
@trujunzhang
trujunzhang / extractGifs.py
Created July 30, 2016 06:30 — forked from revolunet/extractGifs.py
extract frames from animated gif using python+PIL
import os
from PIL import Image
def extractFrames(inGif, outFolder):
frame = Image.open(inGif)
nframes = 0
while frame:
frame.save( '%s/%s-%s.gif' % (outFolder, os.path.basename(inGif), nframes ) , 'GIF')
nframes += 1
@trujunzhang
trujunzhang / hosted_example.txt
Created April 30, 2016 07:26 — forked from makevoid/hosted_example.txt
JQuery DOM HighLighter (it's a basic "Inspect element" simple implementation to mimic what webkit inspector and firebug do)
http://uploads.makevoid.com/jquery_dom_highlighter.html
@trujunzhang
trujunzhang / Install Composer to use MAMP's PHP.md
Created February 23, 2016 03:15 — forked from kkirsche/Install Composer to use MAMP's PHP.md
How to install Composer globally using MAMP's PHP

##Create an alias to MAMP's PHP installation

To do this, we can simply create an alias for our bash profile. We'll be doing this is nano, though you can do it in vim or a number of other editors as well.

Within the terminal, run:

nano ~/.bash_profile

This will open nano with the contents, at the top in a blank line add the following line:

@trujunzhang
trujunzhang / ReactNative-Deep-Dive.md
Created January 29, 2016 12:48 — forked from nsimmons/ReactNative-Deep-Dive.md
ReactNative Deep Dive
atom-sync-settings:
@trujunzhang
trujunzhang / 0_reuse_code.js
Created January 28, 2016 03:32
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console