Skip to content

Instantly share code, notes, and snippets.

@henriquemoody
henriquemoody / ArgoUML.sh
Created August 15, 2012 19:22
Install ArgoUML on linux
#!/bin/sh
if [ "root" != "$(whoami)" ]; then
echo "You must run this command as root" 1>&2
exit 1
fi
set -x
# Download and extract
if [ ! -z "${1}" ]; then
@henriquemoody
henriquemoody / sublime-text-2.sh
Last active May 22, 2024 16:09
Install Sublime Text on Fedora.
#!/usr/bin/env bash
# Usage: {script} [ OPTIONS ] TARGET VERSION
#
# TARGET Default target is "/usr/local".
# VERSION If not defined tries to get the build into the Sublime Text 2 website.
#
# OPTIONS
#
# -h, --help Displays this help message.
#
@henriquemoody
henriquemoody / sql_formater.php
Created August 7, 2012 00:12 — forked from augustohp/sql_formater.php
SQL formater for PHP by @alganet
function formatSql($sql) {
return preg_replace(
'/(select|from|(left |right |natural |inner |outer |cross |straight_)*join|where|limit|update |set|insert |values)/i',
"\n$1\n ", str_replace("\n", '', $sql)
);
}
<?php
// https://wiki.archlinux.org/index.php/Color_Bash_Prompt
$colors = array(
// regular colors
'black' => '0;30', // black
'red' => '0;31', // red
'green' => '0;32', // green
'yellow' => '0;33', // yellow
@henriquemoody
henriquemoody / content-finder.bash
Last active October 6, 2015 18:18
[content-finder] Find content into files.
#!/usr/bin/env bash
# Usage: {script} OPTIONS
# Find content into files.
#
# -h, --help Displays this help
# -a, --action Action to perform: "search", "files" or a sed pattern to
# apply to files (default "search")
# -d, --directory Directory to search (default ".")
# -e, --extension Extensions to search on (default "*")
# -x, --exclude Pattern to exclude
#!/bin/sh
command="/usr/local/sublimetext-2/sublime_text"
if [ -d "${1}" ] || [ -f "${1}" ]
then
${command} -a "${1}" 2>/dev/null 1>&2 &
else
${command} $@
fi
@henriquemoody
henriquemoody / cli.php
Created June 18, 2012 14:59
PHP CLI script in procedural style
<?php
function writeln($message = '', $stream = STDOUT)
{
fwrite($stream, $message . PHP_EOL);
}
$arg_options = array(
'help' => array(
'required' => false,
@henriquemoody
henriquemoody / sorld.sh
Created June 18, 2012 12:51
Run Solr as daemon
#!/usr/bin/env bash
SOLR_RUNNING=0
SOLR_DIRECTORY="/usr/local/solr"
SOLR_LOG="${SOLR_DIRECTORY}/logs/solrd.log"
SOLR_LOCK="${SOLR_DIRECTORY}/solrd.pid"
touch "${SOLR_LOCK}"
SOLR_PID=$(cat ${SOLR_LOCK})
let SOLR_PID=SOLR_PID+0
touch "${SOLR_LOG}"
@henriquemoody
henriquemoody / bin.sh
Created May 19, 2012 16:44
I don't have a description for it now. But a have the URL http://git.io/bin
#!/usr/bin/env bash
echo "I'll do something"
@henriquemoody
henriquemoody / recterm.sh
Created May 8, 2012 21:41
Record the terminal session and replay later
#!/bin/bash
# Uses script and scriptreplay to record and playback virtual terminal.
# Copyright (C) 2007 Hean Kuan Ong <mysurface@gmail.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,