Skip to content

Instantly share code, notes, and snippets.

@otsuarez
otsuarez / check-service.sh
Created December 4, 2015 18:02
using bash to monitor services
#!/bin/bash
SERVICE=myservice
PORT=1234
FILE=/var/tmp/.service-${SERVICE}-down
if [ -f ${FILE} ]; then
exit 0
fi

using pip offline

offline = no internet access

pip install virtualenv
pip install virtualenvwrapper
source /usr/local/bin/virtualenvwrapper.sh
mkvirtualenv
mkdir ~/src/python
@otsuarez
otsuarez / drush-sql-dump.sh
Created September 21, 2015 19:37
drupal database dump in one command using drush
drush sql-dump --gzip --result-file=/var/tmp/$(drush sql-connect | cut -f2 -d= | awk '{print $1}')-$(date +%Y%m%d).sql
@otsuarez
otsuarez / slack.sh
Last active August 29, 2015 14:23 — forked from zdk/slack.sh
#!/bin/bash
WEBHOST_NAGIOS="<Host that nagios is runing on>"
SLACK_CHANNEL="#<Channel name>"
SLACK_BOTNAME="<Bot Name>"
WEBHOOK_URL="<Webhook URL>" #Get it from Slack Incoming WebHooks setup instruction
#Set the message icon based on Nagios service state
# supported emoji table available at http://unicodey.com/emoji-data/table.htm
if [ "$NAGIOS_SERVICESTATE" = "OK" ]
@otsuarez
otsuarez / start-vm.cmd
Created April 3, 2015 16:48
start vm script
cd "c:\Users\John\vms\trusty64\"
vagrant up
start "" "c:\Program Files\Jonn\Putty.exe"
exit
#!/usr/bin/env python
# Try to determine how much RAM is currently being used per program.
# Note per _program_, not per process. So for example this script
# will report RAM used by all httpd process together. In detail it reports:
# sum(private RAM for program processes) + sum(Shared RAM for program processes)
# The shared RAM is problematic to calculate, and this script automatically
# selects the most accurate method available for your kernel.
# Licence: LGPLv2
@otsuarez
otsuarez / README.md
Created August 17, 2014 12:46
cotizacion del dolar

Se crea una carpeta llamada dolar para mantener el codigo separado del resto de la aplicacion.

Dentro de esta carpeta se crean dos archivos. Uno php que es el encargado de actualizar la cotizacion y otro json que contiene la cotizacion.

Se configura un cron job (tarea periodica) para que ejecute el archivo php una vez al dia (le pegue a la url que seria http://dominio/dolar/hoy.php donde dominio es el que sirve el hosting).

La aplicacion va a utilizar http://dominio/dolar/hoy.json para obtener el valor de la cotizacion, asi nuestra app no falla si el servicio remoto no funciona y tambien respetamos los recursos del equipo de geeklab.

El servicio de geeklabs se encuentra descrito en este articulo.

@otsuarez
otsuarez / hubot-festival.md
Last active April 5, 2019 17:41
hubot say

En la oficina cuando un colega no te atiende por IRC le pegas un grito y problema resuelto. Pero que pasa cuando estas trabajando remoto desde casa y no te atiende por IRC?

La solución es sencilla: darle voz al IRC

El bot que utilizamos es hubot, para el text2speech engine festival y se le agregan archivos de sonido en castellano.

instalar festival

sudo apt-get install festival festlex-cmu festlex-poslex festvox-kallpc16k \
@otsuarez
otsuarez / asciinema.screenrc
Created June 25, 2014 14:20
starting a local asciinema.org server
sessionname asciinema
screen -t rails 0 bash -c 'source ~/.rvm/scripts/rvm ; rvm use 2.1.1 ; cd ~/src/github/asciinema.org ; bundle exec rails server'
screen -t sidekiq 1 bash -c 'source ~/.rvm/scripts/rvm ; rvm use 2.1.1 ; cd ~/src/github/asciinema.org ; bundle exec sidekiq'
detach