Skip to content

Instantly share code, notes, and snippets.

@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
@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: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: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: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 / functions.php
Created November 6, 2015 00:15 — forked from jameskoster/functions.php
WooCommerce - Exclude products from a particular category on the shop page
add_action( 'pre_get_posts', 'custom_pre_get_posts_query' );
function custom_pre_get_posts_query( $q ) {
if ( ! $q->is_main_query() ) return;
if ( ! $q->is_post_type_archive() ) return;
if ( ! is_admin() && is_shop() ) {
$q->set( 'tax_query', array(array(
Debug:
keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | openssl sha1 -binary | openssl base64
Release:
keytool -exportcert -alias YOUR_RELEASE_KEY_ALIAS -keystore YOUR_RELEASE_KEY_PATH | openssl sha1 -binary | openssl base64
@th3d0g
th3d0g / gist:d1767895658a6d2c22ed
Created February 22, 2016 21:32
Get Mime Type without FileInfo extension.
// Fix; check mime type without FileInfo extension.
if (function_exists('finfo_file')) {
$mime = finfo_file(finfo_open(FILEINFO_MIME_TYPE), $path);
} else {
$infFil=getimagesize($path);
$mime = $infFil["mime"];
}
@th3d0g
th3d0g / gist:eb958a5d1ed5695536ff
Created March 2, 2016 16:24
DOT Env Loader PHP
// Load either live or dev .env
(new Dotenv\Dotenv(__DIR__.'/../', ( strpos( gethostname(), 'liveserver.com' ) !== false ) ? '.env.live' : '.env' ) )->load();
/////////////////////
// Use ADB over WIFI.
/////////////////////
// Run ADB commands (e.g. logcat) with your device connect via WIFI rather than USB.
// Note; Can be slow to push/install larger APK files.
// 1. Set port.
adb tcpip 5555