Skip to content

Instantly share code, notes, and snippets.

View josue's full-sized avatar
:shipit:
Crushing it from 1999 to Present

Josué Rodriguez josue

:shipit:
Crushing it from 1999 to Present
View GitHub Profile
@josue
josue / keybase.md
Created November 17, 2016 17:44
Keybase

Keybase proof

I hereby claim:

  • I am josue on github.
  • I am josue (https://keybase.io/josue) on keybase.
  • I have a public key whose fingerprint is 6541 1A36 1AD4 7B3F DE71 BA63 0FDD C51D 0813 AEC7

To claim this, I am signing this object:

@josue
josue / docker-mysql.sh
Last active November 16, 2016 00:41
Docker: Create a persistent MySQL data-only container & attach a separate db server:
#!/bin/bash
# author: Josue Rodriguez <code@josue.io>
# (c) October 2016
display_usage_help () {
echo -e "[Usage]"
echo -e "\t${0} -c <mysql data dir> <data-only name> <server name> <server port>"
echo
echo -e "[Examples]"
@josue
josue / xdebugger.sh
Last active May 12, 2016 13:24
xdebugger - Execute php file and outputs xdebug trace and script logs to file for further analyzing.
#/bin/bash
check_xdebug_installed () {
INSTALLED=`php -m | grep xdebug`
if [ "$INSTALLED" = "" ]; then
echo "PHP extention 'xdebug' must be installed."
exit 1
fi
}
@josue
josue / pdf-conversion-fun.md
Last active December 10, 2023 15:11
Using ImageMagick to easily: Split, Merge, Remove a page from PDF.

Install Required libraries:

sudo apt-get update && sudo apt-get install imagemagick gs

create directory to test commands

mkdir -p pdf_conversion/{merged,split}
cd pdf_conversion
@josue
josue / test_uploads.php
Last active October 13, 2015 03:08
Test Uploads - Creates temp files and enqueues them.
<?php
require_once('test_jobs.php');
if (php_sapi_name() === 'cli') {
$upload_options = getopt("",array(
'upload:', // --upload=5
));
}
else if (!empty($_GET['upload'])) {
$upload_options = $_GET;
@josue
josue / test_jobs.php
Last active October 13, 2015 02:26
Test Jobs - Send Resque Jobs to Redis
<?php
// check required Redis module
if (!class_exists('Redis')) {
throw new Exception("Requires PHP Redis extension. Install via: sudo apt-get install php5-redis");
}
class TestJobs {
private $redisInstance = null;
private $redisConfig = array();
@josue
josue / es_quick_info.sh
Created August 26, 2015 16:08
ElasticSearch - Displays quick indices info (name / size / count / alias)
#!/bin/sh
# Ensure file is executable: chmod +x es_quick_info.sh
# Use given host or default to localhost
[ "$1" != "" ] && HOST=$1 || HOST="localhost:9200"
ES_EXIST=`curl -s "$HOST" | grep 'ok'`
if [ "$ES_EXIST" = "" ]; then
@josue
josue / start-mysql-sniffer
Created May 27, 2015 17:30
Start/Stop mysql-sniffer and log data to file
#!/bin/sh
APP="mysql-sniffer"
LOG="/tmp/mysql-sniffer.log"
PID=""
get_pid () {
PID=`ps aux | grep "$APP" | grep -v grep | grep -v "$0" | awk '{ print $2 }'`
}
@josue
josue / mixpanel.php
Created December 16, 2014 20:24
Mixpanel - Simple PHP wrapper using only the mixpanel.track() endpoint.
<?php
// Mixpanel - Simple wrapper using only the mixpanel.track() endpoint.
function Mixpanel($event, $props = array(), $distinct_id = 0) {
$api_key = '{api-key}';
$data = array(
'event' => $event,
'properties' => array(
'distinct_id' => $distinct_id,
'token' => $api_key,
'time' => time()
@josue
josue / es_backup_index_to_new_host.sh
Created October 3, 2014 00:55
ElasticSearch - backup production index from host (1) to host (2) with new index
#!/bin/sh
# Required: npm install elasticdump
# Usage: ./{script} {host-1} {index-to-backup} {host-2} {new-index}
ES_OLD_HOST=$1
ES_OLD_INDEX=$2
ES_NEW_HOST=$3
ES_NEW_INDEX=$4