Skip to content

Instantly share code, notes, and snippets.

View wyanez's full-sized avatar

William Yanez wyanez

View GitHub Profile
@wyanez
wyanez / will_paginate.txt
Created August 9, 2011 05:09
[Rails] Instalación y uso de Will_Paginate
1)Modificamos el config/environment.rb:
Rails::Initializer.run do |config|
config.gem 'will_paginate', :version => '~> 2.3.15', :source => 'http://gemcutter.org'
2) en el controlador:
@arrDatos = Modelo.paginate(:all, :per_page =>10, :page => params[:page])
3) en la vista:
@wyanez
wyanez / int_to_text_pg9.sql
Created September 13, 2011 14:42
Función que permite hacer el cast implicito de int a char en postgres 9
CREATE FUNCTION int_to_text(INT4) RETURNS TEXT AS '
SELECT textin(int4out($1));
' LANGUAGE SQL STRICT IMMUTABLE;
CREATE CAST (INT4 AS TEXT)
WITH FUNCTION int_to_text(INT4)
AS IMPLICIT;
@wyanez
wyanez / cambiar_mem_vz.sh
Created October 21, 2011 20:55
Aumentar la memoria de un contenedor con Open VZ
cid=1000
vzctl set ${cid} --vmguarpages 512M --save
vzctl set ${cid} --oomguarpages 512M --save
vzctl set ${cid} --privvmpages 512M:1024M --save
#Fuente: http://www.linux-os.com.ar/linuxos/como-ampliar-la-memoria-de-un-contenedor-openvz-add-memory-to-a-container-openvz/
@wyanez
wyanez / demo_sqlite.rb
Created October 29, 2011 00:05
[ruby] Ejemplo de conexión Ruby y SQlite
# gem install sqlite3-ruby
require 'sqlite3'
db=SQLite3::Database.new('bdprueba.db');
db.execute("SELECT sqlite_version()") do |reg|
puts "SQLite version: #{reg[0]}"
end
db.close
@wyanez
wyanez / tg_auditoria.sql
Created December 7, 2011 17:45
[pgsql] Modelo de Trigger de Auditoria en PostgreSQL
-- Nota: Se deben sustituir los RAISE por INSERT en las tablas de auditoria
CREATE OR REPLACE FUNCTION auditoria() RETURNS TRIGGER
AS $aud$
DECLARE
inst TEXT;
old_v TEXT;
new_v TEXT;
metadata_record RECORD;
BEGIN
@wyanez
wyanez / git_svn_bash_prompt.sh
Last active September 28, 2015 13:18
[bash] Establece el prompt de acuerdo a la versión de ruby y el status del repositorio de GIT/SVN usado
#!/bin/bash
#
# DESCRIPTION:
#
# Set the bash prompt according to:
# * the ruby version
# * the branch/status of the current git repository
# * the branch of the current subversion repository
# * the return value of the previous command
#
@wyanez
wyanez / ubuntu_import_key.sh
Created January 25, 2012 22:31
Obtener las claves gpg para los mirrors de Ubuntu
gpg --no-default-keyring --keyring trustedkeys.gpg --keyserver keyserver.ubuntu.com --recv-keys 437D05B5
@wyanez
wyanez / no-delete.sql
Created June 29, 2012 15:02
[PLPGSQL] Evitar el borrado de registros en una tabla de postgres
CREATE OR REPLACE FUNCTION proteger_datos() RETURNS TRIGGER AS $proteger_datos$
DECLARE
BEGIN
--
-- Esta funcion es usada para proteger datos en un tabla
-- No se permitira el borrado de filas si la usamos
-- en un disparador de tipo BEFORE / row-level
--
@wyanez
wyanez / lamp-install.sh
Created July 23, 2012 05:46
Instalacion de Servidor LAMP en Debian/Ubuntu
#Instalacion de Servidor LAMP en Debian/Ubuntu
#William Yanez ([email protected]) @wryanez
aptitude install -y apache2 apache2-doc
aptitude install -y php5 php5-cli php5-common php5-dev php5-mysql
aptitude install -y mysql-server
#Habilitar soporte para postgres y sqlite3
#aptitude install -y php5-pgsql php5-sqlite3
@wyanez
wyanez / vm_respaldo.sh
Created July 24, 2012 05:36
[bash] Script para respaldo de las VM con VirtualBox
#!/bin/sh
# Script para respaldo de las VM con VirtualBox
# William Yanez - 07/2012
VM_RUNNING=$(VBoxManage list runningvms | wc -l)
if [ $VM_RUNNING -gt 0 ]; then
echo "Error: Hay $VM_RUNNING VM's Activas"
VBoxManage list runningvms
exit