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 / number-format.js
Last active July 23, 2021 22:09
Funcion para darle formato a un número. #javascript #numbers
function number_format(amount, decimals) {
amount += ''; // por si pasan un numero en vez de un string
amount = parseFloat(amount.replace(/[^0-9\.]/g, '')); // elimino cualquier cosa que no sea numero o punto
decimals = decimals || 0; // por si la variable no fue fue pasada
// si no es un numero o es igual a cero retorno el mismo cero
if (isNaN(amount) || amount === 0)
return parseFloat(0).toFixed(decimals);
@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;
@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
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
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 / 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 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')):
@bnerd
bnerd / enc_h264.sh
Created November 23, 2012 08:44
Simple Encoding with ffmpeg
ffmpeg -i input -r 25 -b:v 1M -bt:v 1.6M -vcodec libx264 -preset medium -acodec -acodec libfaac -ac 2 -ar 44100 -b:a 128k output.mp4
@bnerd
bnerd / ffmpeg
Created November 13, 2012 23:18
Encode RTMP input stream into multiple outputs with ffmpeg
ffmpeg -re -i rtmp://localhost/live/input_stream -acodec libfaac -ab 128k -vcodec libx264 -s 640x360 -b:v 500k -preset medium -vprofile baseline -r 25 -f flv rtmp://localhost/live/medium_500k -acodec libfaac -ab 128k -vcodec libx264 -s 480x272 -b:v 300k -preset medium -vprofile baseline -r 25 -f flv rtmp://localhost/live/medium_300k -acodec libfaac -ab 128k -c:v libx264 -s 320x200 -b:v 150k -preset:v fast -profile:v baseline -level 1.2 -r 25 -f flv rtmp://localhost/live/medium_150k -acodec libfaac -vn -ab 48k -f flv rtmp://localhost/live/audio_only
@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