Skip to content

Instantly share code, notes, and snippets.

View gilfernandes's full-sized avatar

Gil Fernandes gilfernandes

  • Onepoint Consulting Ltd
  • London
View GitHub Profile
@gilfernandes
gilfernandes / spring_hadoop_clone.sh
Created April 24, 2013 15:09
Cloning the Spring Hadoop Examples
cd /home/training
mkdir ~/.git
git config --global gil.fernandes mymail@mail.com
git clone git://github.com/SpringSource/spring-hadoop-samples.git
@gilfernandes
gilfernandes / pom.xml
Created April 24, 2013 15:17
Spring Hadoop Sample pom.xml running on CDH Training VM 4.1.1c
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-hadoop-samples-mapreduce</artifactId>
<name>Spring Hadoop Samples - MapReduce and HDFS</name>
<parent>
<groupId>org.springframework.samples</groupId>
@gilfernandes
gilfernandes / pom.xml
Created April 25, 2013 19:43
Maven Archetype pom file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.osscube</groupId>
<artifactId>spring-hadoop-archetype</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
</project>
@gilfernandes
gilfernandes / Starter.java
Created April 25, 2013 19:46
Main prototype java class for Spring Hadoop
/*
* Copyright 2011-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@gilfernandes
gilfernandes / pom.xml
Created April 25, 2013 19:54
Maven archetype prototype pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<name>Spring Hadoop Project</name>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<version>${version}</version>
<packaging>jar</packaging>
@gilfernandes
gilfernandes / gist:b51f59d25aa283b1667f
Created May 6, 2014 10:12
How to access XA datasource on JBOSS 4 using Groovy
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;
Logger log = Logger.getLogger("DisplayTest1")
@gilfernandes
gilfernandes / gist:c5ee07737f274e294100
Last active August 29, 2015 14:01
How to use connection pools
public static ResultSet executeSingleQuery(String query) throws ConnectorException {
Connection conn = null;
ResultSet data = null;
PreparedStatement stmt = null;
try {
conn = ConnectionFactory.LARGE.getConnection(dbDriver, dbUrl, dbUserName, dbPassword);
log.log(Level.INFO, "Query: {0}", query);
data = conn.prepareStatement(query).executeQuery();
} catch (final SQLException sqle) {
log.log(Level.INFO, "Error SQLException: {0}", sqle.getMessage());
/*
OSSCUBE 2014
*/
package com.onepointltd.file.operations;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
public class ConversionUtils {
/**
* What happens if number is really null?
*/
public static double toDouble(Number number) {
return number != null ? number.doubleValue() : null;
}
@gilfernandes
gilfernandes / extractProcess.jl
Last active August 29, 2015 14:03
Extract regex patterns from multiple files
# All the files from which the text is to be extracted
allFiles = ["MTMImportAll.txt", "ExportAll.txt"]
# Start looping
for fName in allFiles
# Open the file and read everything
f = open("src/test/resources/$fName")
println("******* Processing $f ****************")
array = readlines(f)
close(f)
# End reading file