Skip to content

Instantly share code, notes, and snippets.

@th3d0g
th3d0g / gist:6cd57c6d0badc5772480
Last active October 19, 2015 21:30 — forked from anonymous/gist:5f401192b236f8daaf1c
Sensei - Tag Courses
// Sensei - Add tags to Courses
// Run this after "register_post_type( 'course'..." in "class-woothemes-sensei-posttypes.php"
register_taxonomy(
'course_tag',
'course',
array(
'hierarchical' => false,
'label' => __( 'Tags', CURRENT_THEME ),
'singular_name' => __( 'Tag', CURRENT_THEME ),
@th3d0g
th3d0g / gist:b89969ce025e4ff75ba3
Created July 15, 2015 12:44
Resize Video to Video Tag Dimensions - jQuery
// Resize Video
var video = document.getElementById('video');
$( video ).on('loadeddata', function(event){
scaleToFill( document.getElementById('video') );
});
// Resize Video to Video Tag Dimensions
function scaleToFill(videoTag) {
var $video = $(videoTag),
videoRatio = videoTag.videoWidth / videoTag.videoHeight,
@th3d0g
th3d0g / gist:66ba9340ca6dcb49b735
Last active August 29, 2015 14:22
Wordpress - Different DB details for local/live; works with HOSTS file set to live domain.
<?php
// Use different password if running site locally or on server.
//
if(in_array($_SERVER['REMOTE_ADDR'], array('localhost', '127.0.0.1'))) {
define('DB_PASSWORD', 'rewinded'); // Dev
} else {
define('DB_PASSWORD', 'HcoWtiebscZU0lTqZt5y'); // Live
}
@th3d0g
th3d0g / gist:8678500a3a1f6e8e8889
Created November 26, 2014 16:40
Flambe - Get Pixel Colour
// Returns the colour of a pixel.
// ImageUtils.hx
import flambe.display.Texture;
import haxe.io.Bytes;
import haxe.io.BytesData;
class ImageUtils
{
public static function getPixelColour( x:Float, y:Float, texture:Texture ):Int {
@th3d0g
th3d0g / gist:43350eca4dde1108e567
Created November 18, 2014 00:11
Flambe - Alpha Hit Test
// Checks if a point on a texture hits a pixel with 0 alpha
// @th3d0g
// ImageUtils.hx
import flambe.display.Texture;
import haxe.io.Bytes;
import haxe.io.BytesData;
class ImageUtils
package nl.stroep.games.components;
import flambe.Component;
import nape.space.Space;
/**
* @author Mark Knol [blog.stroep.nl]
*/
class NapeDebugView extends Component
{
private var _space:Space;
@th3d0g
th3d0g / gist:fe409ee3791493eb581e
Created May 21, 2014 21:07
Canvas fill browser window by setting viewport scale.
var screenScale = 1;
window.devicePixelRatio = window.devicePixelRatio || Math.round(screen.deviceXDPI*10 / screen.logicalXDPI)/10;
// Calc safe zone for pixels.
if( window.devicePixelRatio > 1 ) {
var lScreenWidth = Math.max( screen.width, screen.height ) * window.devicePixelRatio;
var lScreenHeight = Math.min( screen.width, screen.height ) * window.devicePixelRatio;
var SAFE_ZONE_WIDTH = 2048;
@th3d0g
th3d0g / waitFor.js
Created April 23, 2014 22:07
Wait until the test condition is true or a timeout occurs.
/**
* Wait until the test condition is true or a timeout occurs. Useful for waiting
* on a server response or for a ui change (fadeIn, etc.) to occur.
*
* @param testFx javascript condition that evaluates to a boolean,
* it can be passed in as a string (e.g.: "1 == 1" or "$('#bar').is(':visible')" or
* as a callback function.
* @param onReady what to do when testFx condition is fulfilled,
* it can be passed in as a string (e.g.: "1 == 1" or "$('#bar').is(':visible')" or
* as a callback function.
@th3d0g
th3d0g / simclick.js
Created April 23, 2014 21:36
Simulate Click in Javascript
// Simulate mouseclick in native JS
function simClick( el ){
var event = new MouseEvent('click', {
'view': window,
'bubbles': true,
'cancelable': true
});
var canceled = !el.dispatchEvent(event);
if (canceled) {
<meta itemprop="name" content="[ TITLE ]" />
<meta itemprop="image" content="[ LISTING IMAGE ]" />
<meta itemprop="description" content="[ ARTICLE DESCRIPTION ]" />
<meta name="description" content="[ ARTICLE DESCRIPTION ]" />
<meta name="author" content="[ AUTHOR FULL NAME ]" />
<meta property="article:author" content="[ GOOGLE+ AUTHOR URL ]" />
<meta property="article:published_time" content="[ PUBLISHED TIMESTAMP ]" />
<meta property="article:section" content="[ CATEGORY ]" />