Skip to content

Instantly share code, notes, and snippets.

View wyanez's full-sized avatar

William Yanez wyanez

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / corregir_certificado_ssl_mercurial.txt
Created August 8, 2011 16:05
[mercurial] Corregir error con certificado del servidor
Si al hacer un hg
$ hg clone https://192.168.10.205/hg/sas_2011
abort: error: _ssl.c:497: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
1) Ejecutamos esta linea en la consola:
$echo quit |openssl s_client -connect 192.168.10.205:443 2>/dev/null|awk '/---BEG/,/--END/' |openssl x509 -fingerprint -noout
2) y obtenemos:
SHA1 Fingerprint=64:A4:7F:0C:39:A4:81:00:81:BC:44:75:18:31:32:22:3F:EB:E8:BE
@wyanez
wyanez / ssh_config
Created August 8, 2011 14:44
[ssh]Formato del archivo de Configuración para ssh ~/.ssh/config (Permite asignar nombres logicos a las conexiones)
Host nombre_logico
Hostname 192.168.10.1
User usuario
Port 22
# Nota: Este archivo vá en: ~/.ssh/config