Skip to content

Instantly share code, notes, and snippets.

@jgcasta
jgcasta / GetExtent
Last active December 12, 2015 08:58
Get the extent from a shapefile
#!/usr/bin/env python
# -*- coding: utf-8
"""
Get extent from SHP
version 1.0
autor José Gómez Castaño
email jgcasta@gmail.com
@jgcasta
jgcasta / plotHistogram
Last active December 12, 2015 09:09
Plot histogram data
#! /usr/bin/env python
# -*- coding: utf-8
"""
Plot histogram
version 1.0
autor José Gómez Castaño
email jgcasta@gmail.com
@jgcasta
jgcasta / AnalemaMadrid
Created February 21, 2013 23:05
Plot an Analema visible from Madrid
#!/usr/bin/python
"""
Traza la Analema para un Madrid
@precondition: se necesita tener el paquete Ephem
"""
import ephem
@jgcasta
jgcasta / DeleteOracle
Created February 22, 2013 11:50
Delete oracle old entries shell script
#!/bin/bash
# Delete 1 year before today
#
# 20/02/2013 v1.0
#
#
ANO=$(date +%Y)
@jgcasta
jgcasta / AddCentos5Repositories
Created March 16, 2013 11:51
Add and update EPEL and RPMFusion repositories in a CentOS 5
#!/bin/bash
# Add and update EPEL and RPMFusion repositories in a CentOS 5
# jgcasta at gmail dot com
wget http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
wget http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
rpm -import RPM-GPG-KEY.dag.txt
rpm -ivh rpmforge-release-0.3.6-1.el5.rf.i386.rpm
rpm -ivh http://mirror.chpc.utah.edu/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
@jgcasta
jgcasta / date2XMLGregorianCalendar.java
Last active December 16, 2015 21:39
Return a XMLGregorianCalendar from a Date object in java
public static XMLGregorianCalendar date2XMLGregorianCalendar(Date fecha, Date hora) {
Calendar calendarFecha = Calendar.getInstance();
calendarFecha.setTime(fecha);
Calendar calendarHora = Calendar.getInstance();
calendarHora.setTime(hora);
//System.out.println("hora->" + calendarHora.get(Calendar.HOUR_OF_DAY) + "/" + calendarHora.get(Calendar.MINUTE) + "/" +calendarHora.get(Calendar.SECOND));
@jgcasta
jgcasta / loadExternalFiles.xml
Last active April 21, 2018 17:25
Spring bean to describe how to load external property file, and Log4j.properties
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
@jgcasta
jgcasta / MavenCheatSheet.txt
Created May 11, 2013 20:18
Maven Cheat Sheet
Install an external dependency into the local repository
$ mvn install:install-file -Dfile=<path-to-file> -DgroupId=Id=<group-id> -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>
Generate a package
$ mvn package
Install into the local repository
@jgcasta
jgcasta / ShellDeleteOracleRecords.sh
Last active January 2, 2016 16:39
Delete Oracle records from a bash shell script
#!/bin/bash
#Delete Oracle table since 1 natural year
#
ANO=$(date +%Y)
ANTERIOR=$[ANO-1]
FBORRADO=$(date +%d-%m-$ANTERIOR)
MES=$(date +%m)
MESANTERIOR=$[MES-1]
@jgcasta
jgcasta / XmlGregorianCalendar2String.java
Last active August 29, 2015 13:55
Return a String date with format dd-MM-yyyy from a XMLGregorianCalendar
/**
* Return a String date with format dd-MM-yyyy from a XMLGregorianCalendar
*
* @param cal
* @return
*/
public String XmlGregorianCalendar2String(XMLGregorianCalendar cal){
String str = "";
SimpleDateFormat format = new SimpleDateFormat("dd-MM-yyyy");