Skip to content

Instantly share code, notes, and snippets.

View jrobinsonc's full-sized avatar
🎯
Focusing

Jose Robinson jrobinsonc

🎯
Focusing
View GitHub Profile
@jrobinsonc
jrobinsonc / imagettftext_in_lines.php
Last active August 29, 2015 14:15
Write text to the image using TrueType fonts and split text into several lines based on a width size.
<?php
/**
* imagettftext_in_lines
*
* @author JoseRobinson.com
* @link https://gist.github.com/jrobinsonc/699ea6fadd7369146574
* @version 201502131102
* @param $image An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().
* @param $font_size The font size. Depending on your version of GD, this should be specified as the pixel size (GD1) or point size (GD2).
@jrobinsonc
jrobinsonc / get_thumb_tag.php
Last active August 29, 2015 14:16
Wordpress helper: Get image tag.
<?php
/**
* get_thumb_tag
*
* @author JoseRobinson.com
* @link https://gist.github.com/jrobinsonc/3959a3c40138fdb701c8
* @version 201506211936
* @param int $post_id
* @param mixed $size
@jrobinsonc
jrobinsonc / hex2rgb.php
Created March 9, 2015 19:32
Function for converting colors from hexadecimal to RGB.
function hex2rgb($hex)
{
$hex = str_replace("#", "", $hex);
if(strlen($hex) === 3)
{
$r = hexdec(substr($hex,0,1).substr($hex,0,1));
$g = hexdec(substr($hex,1,1).substr($hex,1,1));
$b = hexdec(substr($hex,2,1).substr($hex,2,1));
}
@jrobinsonc
jrobinsonc / breakpoint.scss
Last active March 21, 2020 19:30
SASS, SCSS mixins
$breakpoints: (
"sm": ( min-width: 640px ),
"md": ( min-width: 768px ),
"lg": ( min-width: 1024px ),
"xl": ( min-width: 1280px )
);
// Usage
// @include breakpoint(xs) { ... }
@jrobinsonc
jrobinsonc / get_breadcrumbs.php
Last active August 29, 2015 14:22
Wordpress helper: get_breadcrumbs.
<?php
/**
* get_breadcrumbs
*
* @author JoseRobinson.com
* @link https://gist.github.com/jrobinsonc/f93d9462ebea6be138d0
* @param string $home_label
* @param string $separator
* @return string
@jrobinsonc
jrobinsonc / is_parent.php
Last active January 23, 2016 19:50
Wordpress helper: is_parent
<?php
/**
* is_parent
*
* @author JoseRobinson.com
* @link https://gist.github.com/jrobinsonc/e6098d90453d58f31793
* @param int $pid
* @return bool
*/
@jrobinsonc
jrobinsonc / angularjs-filter-ucwords.js
Last active April 7, 2016 01:49
Angular filter: Capitalize words
angular.module('mymodule').filter('ucwords', function() {
return function(input,arg) {
return input.replace(/(?:^|\s)\S/g, function(a) { return a.toUpperCase(); });
};
});
@jrobinsonc
jrobinsonc / repeat.js
Created August 12, 2015 13:25
Repeat String - Javascript
String.prototype.repeat = function( num )
{
return new Array( num + 1 ).join( this );
}
alert( "string to repeat\n".repeat( 4 ) );
@jrobinsonc
jrobinsonc / wp-widget-php.php
Created August 31, 2015 23:24
Wordpress filter: Execute PHP from widgets.
<?php
/**
* Execute PHP from widgets.
*/
add_filter('widget_text', function ($html){
if(strpos($html, "<"."?php") !== false)
{
ob_start();
@jrobinsonc
jrobinsonc / wp-create-thumb.php
Last active April 7, 2016 01:52
Wordpress helper: create_thumb.
<?php
/**
* create_thumb
*
* @author JoseRobinson.com
* @link https://gist.github.com/jrobinsonc/b40c99a4d688f8a2d554
* @param string $file_src_path
* @param int $width
* @param int $height