Skip to content

Instantly share code, notes, and snippets.

Avatar
:shipit:
Crushing it from 1999 to Present

Josué Rodriguez josue

:shipit:
Crushing it from 1999 to Present
View GitHub Profile
View keybase.md

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 Nov 16, 2016
Docker: Create a persistent MySQL data-only container & attach a separate db server:
View docker-mysql.sh
#!/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
xdebugger - Execute php file and outputs xdebug trace and script logs to file for further analyzing.
View xdebugger.sh
#/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 Nov 30, 2021
Using ImageMagick to easily: Split, Merge, Remove a page from PDF.
View pdf-conversion-fun.md

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 Oct 13, 2015
Test Uploads - Creates temp files and enqueues them.
View test_uploads.php
<?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 Oct 13, 2015
Test Jobs - Send Resque Jobs to Redis
View test_jobs.php
<?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 Aug 26, 2015
ElasticSearch - Displays quick indices info (name / size / count / alias)
View es_quick_info.sh
#!/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
Start/Stop mysql-sniffer and log data to file
View start-mysql-sniffer
#!/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 Dec 16, 2014
Mixpanel - Simple PHP wrapper using only the mixpanel.track() endpoint.
View mixpanel.php
<?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 Oct 3, 2014
ElasticSearch - backup production index from host (1) to host (2) with new index
View es_backup_index_to_new_host.sh
#!/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