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 / 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 / dump-resque-failed-jobs
Last active August 29, 2015 13:57
Dump all resque-web failed jobs from IP address
#!/bin/sh
# To extract from localhost '127.0.0.1:6379', you can quickly do:
# usage: curl -L http://git.io/dump-resque-failed-jobs-test | sh
[ "$1" != "" ] && IP=$1 || IP=127.0.0.1
[ "$2" != "" ] && PORT=$2 || PORT=6379
redis-cli -h $IP -p $PORT LRANGE resque:failed 0 -1
@josue
josue / check_if_beast.hs
Created July 18, 2014 19:18
Experimenting with Haskell - simple script that reads name, validates with functions and writes output to file.
import System.Environment
import Data.Char
main = promptNameAndSave
matchesName s = if (map toUpper s) == "JOSUE" then True else False
checkIfBeast str = if matchesName str then "a BEAST !" else "normal."
finalMessage h i = "Thanks " ++ h ++ ", you are " ++ i
@josue
josue / client-startup.sh
Created August 21, 2014 20:13
Checks if client services (ElasticSearch + background jobs) are running
#!/bin/sh
CLIENT=$1
DIR_DEPLOY="/var/www/vhosts/deploy"
CLIENT_DIR="$DIR_DEPLOY/$CLIENT"
echo "- Switching to client dir: $CLIENT_DIR"
cd $CLIENT_DIR
echo
@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 / 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 }'`
}
CmdUtils.CreateCommand({
names: ["php"],
icon: "http://static.php.net/www.php.net/favicon.ico",
description: "Check PHP function specs and comments. (v0.4)",
help: "PHP",
author: {name: "Josue Rodriguez", email: "josue@josuerodriguez.com"},
license: "MIT",
homepage: "http://josuerodriguez.com",
arguments: [
{role: "object", label: 'function', nountype: noun_arb_text}
#!/bin/bash
# ========== Your Server Config ==========
# your SSH credentials ...
SSH_User="user"
SSH_Host="server.com"
# directory where the tar.gz file will be uploaded then extracted from.
# recommened it be root directory so when you untar it falls nicely into place...
WWW_Dir="html/"
#!/bin/bash
# Author: Josue Rodriguez (@JosueR)
# Grabs the current pwd via Git repo then performs a php syntax on all php files.
me="$(basename "$(test -L "$0" && readlink "$0" || echo "$0")")"
Git_Root=$(readlink -f ./$(git rev-parse --show-cdup))
option=$1
files_found=0
counter=0
#!/bin/bash
# file: tweet
# NOTE: make sure to put this file in '/usr/bin' and make it executable: sudo chmod +x /usr/bin/tweet
# usage: tweet "hello from CLI"
user="USERNAME"
pass="PASSWORD"
tweet=$1