Skip to content

Instantly share code, notes, and snippets.

View rememberlenny's full-sized avatar

Leonard Bogdonoff rememberlenny

View GitHub Profile
@rememberlenny
rememberlenny / taxmeta.class.php
Created May 20, 2012 04:36 — forked from jonathonbyrdziak/taxmeta.class.php
Taxonomy Metaboxes, allows you to create additional taxonomy metas, including images.
<?php
/**
* @Author Anonymous
* @link http://www.redrokk.com
* @Package Wordpress
* @SubPackage RedRokk Library
* @copyright Copyright (C) 2011+ Redrokk Interactive Media
*
* @version 2.0
*/
@rememberlenny
rememberlenny / gist:4316395
Created December 17, 2012 07:16
WooCommerece: Adding China's Provinces to shipping locations. Snippet should go in child-theme's functions.php.
/**
* Code goes in functions.php or a custom plugin. Replace XX with the country code your changing.
*/
add_filter( 'woocommerce_states', 'custom_woocommerce_states' );
function custom_woocommerce_states( $states ) {
$states['CN'] = array(
'CN1' => 'Yunnan / 云南',
'CN2' => 'Beijing / 北京',
<canvas id="myCanvas" width="578" height="500"></canvas>
<script type="text/javascript">
var canvas = document.getElementById('myCanvas');
var context = canvas.getContext('2d');
context.lineWidth = 10;
<canvas id="myCanvas" width="578" height="500"></canvas>
<script type="text/javascript">
var canvas = document.getElementById('myCanvas');
var context = canvas.getContext('2d');
context.lineWidth = 10;
@rememberlenny
rememberlenny / gist:4368627
Created December 24, 2012 09:49
WooCommerce Paypal snippet to convert checkout price with currency conversion rate. Written by: http://www.solagirl.net/
add_filter('woocommerce_paypal_args', 'convert_rmb_to_usd');
function convert_rmb_to_usd($paypal_args){
if ( $paypal_args['currency_code'] == 'RMB'){
$convert_rate = 6.2116;
$paypal_args['amount_1'] = round( $paypal_args['amount_1'] / $convert_rate, 2);
}
return $paypal_args;
}
@rememberlenny
rememberlenny / gist:4368854
Created December 24, 2012 11:05
Image loader function that takes in a hash of image sources, creates an hash of images, and then calls a user defined function whenever all of the images have loaded. From http://www.html5canvastutorials.com/tutorials/html5-canvas-image-loader/
<script>
function loadImages(sources, callback) {
var images = {};
var loadedImages = 0;
var numImages = 0;
// get num of sources
for(var src in sources) {
numImages++;
}
for(var src in sources) {
var canvas = document.getElementById('tutorial');
if (canvas.getContext){
var ctx = canvas.getContext('2d');
// drawing code here
} else {
// canvas-unsupported code here
}
@rememberlenny
rememberlenny / gist:4369507
Created December 24, 2012 14:53
Rotate an object so that its front is always facing the direction its moving in. http://visitmix.com/Articles/Translating-CANVAS-with-HTML5
ctxRoot.rotate(Math.atan2(temp.vy, temp.vx));
@rememberlenny
rememberlenny / gist:4369915
Last active December 10, 2015 02:48
Firefox 1.5 quadraticCurveTo() bug workaround There is a bug in the Firefox 1.5 implementation of quadatricCurveTo(). It does NOT draw a quadratic curve, as it is just calling the same cubic curve function bezierCurveTo() calls, and repeating the single quadratic control point (x,y) coordinate twice. For this reason quadraticCurveTo() will yield…
var currentX, currentY; // set to last x,y sent to lineTo/moveTo/bezierCurveTo or quadraticCurveToFixed()
function quadraticCurveToFixed( cpx, cpy, x, y ) {
/*
For the equations below the following variable name prefixes are used:
qp0 is the quadratic curve starting point (you must keep this from your last point sent to moveTo(), lineTo(), or bezierCurveTo() ).
qp1 is the quadratic curve control point (this is the cpx,cpy you would have sent to quadraticCurveTo() ).
qp2 is the quadratic curve ending point (this is the x,y arguments you would have sent to quadraticCurveTo() ).
We will convert these points to compute the two needed cubic control points (the starting/ending points are the same for both
the quadratic and cubic curves.
@rememberlenny
rememberlenny / part-of-gruntfile.js
Created March 8, 2013 16:24
Adding rendering of Foundation to compass in Gruntfile.js
compass: {
options: {
sassDir: '<%= yeoman.app %>/css',
cssDir: '.tmp/css',
imagesDir: '<%= yeoman.app %>/images',
javascriptsDir: '<%= yeoman.app %>/scripts',
fontsDir: '<%= yeoman.app %>/fonts',
importPath: 'app/components',
relativeAssets: true,
require: 'zurb-foundation'