Skip to content

Instantly share code, notes, and snippets.

View angoca's full-sized avatar
🏠
Working from home

Andres Gomez Casanova angoca

🏠
Working from home
View GitHub Profile
#!/bin/bash
# Downloads all public traces on OpenStreetMap for a given user.
# This requires gunzip and bzip2 to extract the compressed traces.
# Also, wget to retrieve the traces from OSM.
#
# Arguments.
# 1) Username. If the username has spaces, you should provide the name between quotes.
#
# Version: 2024-05-26
@angoca
angoca / generate_insert.sql
Last active May 21, 2021 04:18
Generate Insert statement from Select
--#SET TERMINATOR @
--SET SERVEROUTPUT ON@
/**
* Function that returns a string containing the insert statement with the
* values from the fields of a given row id. The case of the tableschame or of
* the tablename could be ignored if the name is stored in uppercase.
* This function does not generate the columns for the following datatypes:
* - XML
@angoca
angoca / pciValidator.sql
Created June 16, 2020 03:21
PCI for Db2 database
--#SET TERMINATOR @
BEGIN
DECLARE VALID SMALLINT;
DECLARE VAL SMALLINT;
DECLARE PROCEDURE LUHN_TEST (
IN NUMBER VARCHAR(24),
OUT RET SMALLINT
)
@angoca
angoca / generateHeaders.sql
Last active July 13, 2020 20:34
Stored procedure in Db2 to generate headers
--#SET TERMINATOR @
SET SERVEROUTPUT ON@
/**
* Creates a temporary table with the headers of a given query.
* A user temporary tablespace is necessary. This is useful when exporting data.
* The table with the header is called: session.header.
*
* IN query
@angoca
angoca / installAll
Created January 20, 2019 23:54
Install all db2 fixpacks
#!/bin/bash
# Script to install a set of different Db2 fixpack in the same machine.
# The prerequisites to install Db2 should have been resolved:
# For V11.1:
# sudo dpkg --add-architecture i386
# sudo apt-get install binutils # strings
# sudo apt-get install libaio1 # libaio.so.1
# sudo apt-get install libpam-ldap:i386 -y -q # libpam
# supo apt-get install lib32stdc++6 -y
@angoca
angoca / installAllFixpacks
Created May 14, 2018 17:50
Installs all Db2 fixpack an creates a different instance for each one
#!/bin/bash
# Script to install a set of different Db2 fixpack in the same machine.
# The prerequisites to install Db2 should have been resolved:
# For V11.1:
# sudo dpkg --add-architecture i386
# sudo apt-get install binutils # strings
# sudo apt-get install libaio1 # libaio.so.1
# sudo apt-get install libpam-ldap:i386 -y -q # libpam
# supo apt-get install lib32stdc++6 -y
@angoca
angoca / lookForObject
Created March 15, 2018 15:39
lookForDb2Object
#!/bin/bash
OBJECT=$2
if [[ -n ${OBJECT} ]] ; then
SCHEMA=$1
else
OBJECT=$1
fi
STMT=""
@angoca
angoca / deadlock
Last active November 23, 2016 14:23
Recreates a DB2 deadlock
#!/bin/bash
DATABASE=sample
TABLE1=t1
TABLE2=t2
db2 connect to ${DATABASE} > /dev/null
db2 "drop table ${TABLE1}" > /dev/null
db2 "drop table ${TABLE2}" > /dev/null
db2 "create table ${TABLE1} (col1 int, col2 varchar(15))"
@angoca
angoca / getAuths
Last active May 27, 2018 22:46
Get all authorization for a given user in DB2 LUW
#!/bin/sh
# Returns all privileges on a database granted to a user.
# The user is passes as first parameter.
#
# Author: Andres Gomez Casanova (AngocA)
# Version: 2016-08-02
# Made in COLOMBIA
DBUSER=$1
@angoca
angoca / renderNsrLog
Last active June 26, 2016 14:40
Render NSR (Networker) log continuosly like tail -f
#!/bin/bash
# Reads the Networker logs periodically.
# By default 15 seconds.
#
# Original from: http://www.backupcentral.com/phpBB2/two-way-mirrors-of-external-mailing-lists-3/emc-networker-19/nsr-render-log-97064/
LOG_FILE=/nsr/logs/daemon.raw
#LOG_FILE=/nsr/apps/logs/nmda_db2.messages.raw
DATE=$(date +"%m/%d/%y %H:%M:%S")