Skip to content

Instantly share code, notes, and snippets.

View mabrizio's full-sized avatar
:octocat:
Nobody cares!

Mauricio Araya V. mabrizio

:octocat:
Nobody cares!
View GitHub Profile
@mabrizio
mabrizio / full-text-with-postgresql.sql
Last active May 1, 2016 03:33
Full Text Search en PostgreSQL, usando un índice GIN.
--
-- La ciencia está en:
--
-- * Agregar un campo en la tabla de tipo tsvector (1), en este caso se llama tsv,
-- podría ponérsele cualquier nombre.
-- * Agregar un índice GIN (2)
-- * Crear un trigger que cuando se inserte o actualice una tupla se actualice la
-- columna tsv (nuestro tsvector)
--
-- 1. http://www.postgresql.org/docs/9.1/static/datatype-textsearch.html
@mabrizio
mabrizio / inputrc
Last active December 30, 2015 23:39
Smart history for ¿bash?
# Agregue lo siguiente al final del /etc/inputrc
"\e[A": history-search-backward
"\e[B": history-search-forward
"\eOA": history-search-backward
"\eOB": history-search-forward
@mabrizio
mabrizio / vim-tips
Last active January 2, 2016 15:39
Vim cool tips
# Remove all lines starting with the "#" character
:g/^#/d
# Show line numbers
:set number
or
:set nu
@mabrizio
mabrizio / etc-init.d-nagios.sh
Last active January 3, 2016 12:39
Nagios service startup script
#!/bin/sh
# Nagios Startup script for the Nagios monitoring daemon
#
# chkconfig: - 85 15
# description: Nagios is a service monitoring system
# processname: nagios
# config: /etc/nagios/nagios.cfg
# pidfile: /var/nagios/nagios.pid
#
@mabrizio
mabrizio / ubuntu-nagios-recipe.sh
Last active January 3, 2016 12:38
Ubuntu + Nagios recipe
# inspired by: http://wellsie.net/p/248/
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install libgd2-xpm-dev apache2 apache2-mpm-prefork \
apache2-threaded-dev apache2-utils apache2.2-bin \
apache2.2-common libapache2-mod-php5 php5 gcc g++ \
make daemon libnet-snmp-perl libperl5.14 libpq5 \
libradius1 libsensors4 libsnmp libcgi-pm-perl \
@mabrizio
mabrizio / apache-visitors-per-ip-per-day.tcsh
Created January 20, 2014 17:27
Visitors per ip per day - Apache
#!/usr/bin/env tcsh
foreach i (`cat access.log | cut -d \] -f1 | cut -d \[ -f2 | cut -d \: -f1 | perl -ne 'print unless $seen{$_}++' `)
printf "$i -> "
printf `grep $i access.log | awk '{print $1}' | sort | uniq | wc -l`
echo " different IPs"
end
@mabrizio
mabrizio / vimrc
Created January 27, 2014 04:29
.vimrc
if v:progname =~? "evim"
finish
endif
set sw=4 "Identation is now 4 white spaces
set nocompatible
set nomodeline
set backspace=indent,eol,start
if has("vms")
set nobackup " do not keep a backup file, use versions instead
else
@mabrizio
mabrizio / robots-from-cloudfront.vcl
Created January 30, 2014 19:32
Robots disallow robots from CloudFront
if (req.url ~ "^/robots.txt$") {
if (req.http.User-Agent ~ "CloudFront")
{
set obj.http.Content-Type = "text/plain; charset=utf-8";
synthetic {"User-agent: *\nDisallow: /"};
}
return (deliver)
}
@mabrizio
mabrizio / bash_profile
Last active August 29, 2015 13:57
Bash Profile
export CLICOLOR=1
export LSCOLORS=gxBxhxDxfxhxhxhxhxcxcx
# green, bold[reset, now, green, bold]reset, bold, pwd:>
export PS1="\[\e[01;32m\]\[\e[1m\][\[\e[0m\]\t\[\e[01;32m\]\[\e[1m\]]\[\e[0m\]\[\e[1m\] \w:>\[\e[0m\] "
# Ctrl w, al estilo tcsh
stty werase undef
bind '"\C-w":backward-kill-word'
@mabrizio
mabrizio / 0_reuse_code.js
Created May 14, 2014 17:58
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console