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 / 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 / README.md
Last active October 5, 2016 19:09
Wordpress: Hide Post Type UI/Menu#wordpress

Wordpress: Hide Post Type UI/Menu

Para eliminar un item del menu se usa la funcion remove_menu_page (Ref: http://codex.wordpress.org/Function_Reference/remove_menu_page)

Eliminar un custom post-type de los usuarios que no son administradores.

function my_remove_menu_items() 
{
    if(!current_user_can('manage_options')):
@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
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.
@jrobinsonc
jrobinsonc / README.md
Last active December 15, 2015 21:19
Get the directory contents recursively. #directories #files #php

Get directory contents

Get the directory contents recursively.

Usage

require 'get_dir.php';

printf('');
@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 / send_mail.php
Created April 15, 2013 13:34
Send emails with PHPMailer.
<?php
/**
* PHPMailer
* Download: https://github.com/Synchro/PHPMailer/archive/master.zip
*/
define('PHPMailer_path', dirname(__FILE__) . '/PHPMailer');
/**
<?php
/**
* Pasar variables por post.
*
* @author JoseRobinson.com
* @version 201304241106
* @link GitHup: https://gist.github.com/5452853
* @param string $url La URL a la cual se le hará la petición.
* @param array $data La data que se quiere enviar.
@jrobinsonc
jrobinsonc / appcache.php
Created May 5, 2013 15:52
AppCache generator #php #appcache
<?php
function get_dir($dir)
{
$files = array();
$exclude = array('.', '..', 'appcache.php', '.git', '.gitignore', 'nbproject', 'TODO', 'README.md', 'cache.manifest');
foreach (scandir($dir) as $item)
{
if (in_array($item, $exclude)) continue;