Skip to content

Instantly share code, notes, and snippets.

@Davidlab
Davidlab / gist:553db99f33393236848a
Last active September 23, 2015 19:05
JS Color Mixer
function shadeBlendConvert(p, from, to) {
if(typeof(p)!="number"||p<-1||p>1||typeof(from)!="string"||(from[0]!='r'&&from[0]!='#')||(typeof(to)!="string"&&typeof(to)!="undefined"))return null; //ErrorCheck
if(!this.sbcRip)this.sbcRip=function(d){
var l=d.length,RGB=new Object();
if(l>9){
d=d.split(",");
if(d.length<3||d.length>4)return null;//ErrorCheck
RGB[0]=i(d[0].slice(4)),RGB[1]=i(d[1]),RGB[2]=i(d[2]),RGB[3]=d[3]?parseFloat(d[3]):-1;
}else{
switch(l){case 8:case 6:case 3:case 2:case 1:return null;} //ErrorCheck
@Davidlab
Davidlab / gist:b40641fba36cd14504fd
Created September 15, 2015 13:42
phpColors w/percent to white or black
<?php
/**
* Author: Arlo Carreon <http://arlocarreon.com>
* Info: http://mexitek.github.io/phpColors/
* License: http://arlo.mit-license.org/
*/
namespace Mexitek\PHPColors;
function np_replace_howdy($wp_admin_bar){
//New text to replace Howdy
$new_text = 'Welcome';
//Call up the 'my-account' menu node for current values.
$my_account = $wp_admin_bar->get_node('my-account');
//Replace the 'Howdy' with new text with string replace
$new_title = str_replace('Howdy', $new_text, $my_account->title);
@Davidlab
Davidlab / 0_reuse_code.js
Created April 7, 2014 11:58
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
@Davidlab
Davidlab / Hide Nextgen Junk
Created March 11, 2013 14:31
Nexgen hide all styles and scripts. Good to use if you are using a third party plugin along side Nexgen that handles the styles and fancy stuff. This will hide all Nexgen junk from loading.
/*
* Hide Nextgen styles and scripts
*/
if (!is_admin()) {
// goodbye NextGen junk
define('NGG_SKIP_LOAD_SCRIPTS', true);
function nextgen_styles() {
wp_deregister_style('NextGEN');
}
add_action('wp_print_styles', 'nextgen_styles', 100);
@Davidlab
Davidlab / Justified Image Grid tag cloud widget
Last active December 14, 2015 19:08
Justified Image Grid Nextgen tags widget. Paste this in your functions.php with https://gist.github.com/Davidlab/5130772 (also creates shortcode, but includes needed function for tags widget). Within this snippet you will see an area where you need to include the page name or ID of your gallery page. This is to allow the widget to only load on t…
class justified_tagcloud_widget extends WP_Widget {
/** constructor */
function justified_tagcloud_widget() {
$widget_ops = array(
'description' => 'Display\'s a Tag Cloud based on Nextgen, used by Justified Image Grid '
);
parent::WP_Widget(false, $name = 'Justified Image Grid Tag Cloud', $widget_ops);
}
@Davidlab
Davidlab / Justified Image Grid Nexgen tags shortcode
Last active December 14, 2015 18:39
Justified Image Grid Nexgen Tags. Paste this into your themes functions.php and use shortcode [justified_ngg_tagcloud]
function justified_tag_cloud($args ='', $template = '') {
global $nggRewrite;
$defaults = array(
'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC',
'exclude' => '', 'include' => '', 'link' => 'view', 'taxonomy' => 'ngg_tag'
);
$args = wp_parse_args( $args, $defaults );
@Davidlab
Davidlab / functions
Created December 31, 2011 14:35
test
/**
* @property wpdb $ID
* @property wpdb $post_author
* @property wpdb $post_date
* @property wpdb $post_date_gmt
* @property wpdb $post_content
* @property wpdb $post_title
* @property wpdb $post_excerpt
* @property wpdb $post_status