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 / 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 / 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 / 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 / example1.php
Last active September 5, 2015 22:15
Wordpress helper: Post views - Set and get the number of views/hits of a post.
<?php
#####################################################
# Example to show most visited posts.
#####################################################
$custom_query = new WP_query(array(
'meta_key' => Posts_views::$key,
'orderby' => 'meta_value_num',
'order' => 'DESC'
@jrobinsonc
jrobinsonc / README.md
Last active October 9, 2015 13:27
jQuery: Disable form #forms #jquery #javascript

Disable Forms

Introduction

Disable the fields of forms. This does not touch the fields that are disabled at the moment of disabling. This script is executed like an event call.

This depends of jQuery.

Usage

@jrobinsonc
jrobinsonc / send_mail.php
Created September 19, 2012 20:15
Enviar email usando la libreria PHPMailer
<?php
/**
* Envio de emails.
*
* @param string $to Destinatario del email.
* @param string $subject Asunto.
* @param string $body Mensaje.
* @param string $alt_body (Opcional) Mensaje en texto plano.
* @return mixed Devuelve TRUE si todo paso bien o un String con el error si algo fallo.
@jrobinsonc
jrobinsonc / rename-user.sh
Last active December 14, 2015 20:39
Git tip: Renombrar usuario de uno o varios commits.
git filter-branch --commit-filter '
if [ "$GIT_COMMITTER_NAME" = "<Old Name>" ];
then
GIT_COMMITTER_NAME="<New Name>";
GIT_AUTHOR_NAME="<New Name>";
GIT_COMMITTER_EMAIL="<New Email>";
GIT_AUTHOR_EMAIL="<New Email>";
git commit-tree "$@";
else
git commit-tree "$@";
@jrobinsonc
jrobinsonc / README.md
Last active December 15, 2015 21:19
Generate random strings. #strings #generator #php

Generate random string

Generate a random string with the specified length. Optionally you can set the chars to use for generate the string.

Usage

require 'generate_string.php';

// Normal usage:
@jrobinsonc
jrobinsonc / README.md
Last active December 15, 2015 21:19
Convert from Bytes to KB, MB, GB, TB, PB, EB, ZB, YB. #php #files

Convert from Bytes to other file size units.

Convert from Bytes to KB, MB, GB, TB, PB, EB, ZB, YB.

Usage

require 'byte_convert.php';

// Get file size in bytes.