Skip to content

Instantly share code, notes, and snippets.

View jsianes's full-sized avatar

Javier Sianes jsianes

  • AWS
  • O Grove, Galicia
  • 04:46 (UTC +02:00)
  • LinkedIn in/jsianes
View GitHub Profile
@jsianes
jsianes / Lottery.java
Created August 18, 2012 10:14
Spotify 'lottery' test program solved
import java.util.Scanner;
import java.io.BufferedInputStream;
public class Lottery {
public static double LotteryProbability (String lottery) {
int m=0,n=0,t=0,p=0,requiredForWin=0;
double result=0.0;
String[] number = lottery.split(" ");
@jsianes
jsianes / BestBefore.java
Created August 18, 2012 10:23
Spotify 'best before' test program solved
import java.util.Date;
import java.util.Scanner;
import java.util.LinkedList;
import java.util.Iterator;
import java.text.SimpleDateFormat;
public class BestBefore {
//Verify if it is a leap year
public static boolean isaleapyear (int year) {
@jsianes
jsianes / fsx.cfg
Last active December 15, 2015 07:48
FSX main config file
[DISPLAY.Device.NVIDIA GeForce GTX 780.0]
Anisotropic=1
MipBias=6
Mode=1920x1080x32
WideViewAspect=False
TEXTURE_BANDWIDTH_MULT=100
[MAPVIEW_MAP]
SHOW_AIRPORTS=1
SHOW_AIRSPACE=1
@jsianes
jsianes / WordCount.java
Created May 23, 2013 20:30
WordCount example from Hadoop
package org.myorg;
import java.io.IOException;
import java.util.*;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.conf.*;
import org.apache.hadoop.io.*;
import org.apache.hadoop.mapreduce.*;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
@jsianes
jsianes / wordcount_exec
Last active December 17, 2015 16:29
Execution result for WordCount Hadoop example
[ambari-qa@master-node ~]$ hadoop dfs -ls ./entrada
Found 2 items
drwx------ - ambari-qa hdfs 0 2013-05-23 18:41 /user/ambari-qa/entrada/entrada
-rw------- 3 ambari-qa hdfs 568233984 2013-05-23 20:31 /user/ambari-qa/entrada/input1.txt
[ambari-qa@master-node ~]$ hadoop jar /usr/lib/hadoop/hadoop-examples.jar wordcount ./entrada/input1.txt ./salida
13/05/23 20:38:15 INFO input.FileInputFormat: Total input paths to process : 1
13/05/23 20:38:15 INFO lzo.GPLNativeCodeLoader: Loaded native gpl library
13/05/23 20:38:15 INFO lzo.LzoCodec: Successfully loaded & initialized native-lzo library [hadoop-lzo rev cf4e7cbf8ed0f0622504d008101c2729dc0c9ff3]
13/05/23 20:38:15 WARN snappy.LoadSnappy: Snappy native library is available
13/05/23 20:38:15 INFO util.NativeCodeLoader: Loaded the native-hadoop library
@jsianes
jsianes / XmltoJson.java
Last active December 19, 2015 01:18
A short Java program that takes any XML file from input and generates a JSON compliant document
import java.io.*;
import java.util.*;
import org.json.*;
/*
JSON library provided by json.org (http://www.json.org/)
*/
public class XmltoJson {
public static void main(String[] args) {
@jsianes
jsianes / mergeExcel.java
Last active April 4, 2016 19:39
A Java application using Apache POI library for merging Excel files
import java.io.*;
import java.util.Map;
import java.util.Vector;
import java.util.HashMap;
import java.util.StringTokenizer;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
@jsianes
jsianes / CSTranslator.sh
Last active December 19, 2015 01:19
A bash shell-script that takes several CSV as input and generates an unified and restructured CSV output
#!/bin/bash
#
# Developed by: Javier Sianes - jsianes@gmail.com
#
# Exit codes:
# 0: Correct program execution
# 1: Total hours doesn't match with partial aggregate hours
# 2: General error or program execution interrupted
# 3: Can't match resource as intern or extern
# 4: Error in command line execution
@jsianes
jsianes / backup-BBDD.sh
Last active January 24, 2022 09:56
This shell-script creates a local MySQL backup file, maintaining a 10 days rotation period (by default. Can be configured on parameters). Controls if there is enough space before doing it and overlap executions.
#!/bin/bash
#
# This script make a local MySQL DB backup
# Developed for RHEL5 by Javier Sianes - jsianes@gmail.com
#
# Start of Parameters
##############################################
USUARIO="username"
PASSWORD="password"
@jsianes
jsianes / LCAP.java
Last active December 19, 2015 17:49
This Java code helps you to analyze economic proposals of a contest according to art.85 hiring law of Public Administrations in Spain (Real Decreto 1098/2001,Reglamento LCAP - artículo 85: http://is.gd/uANADN )
import java.io.*;
import java.util.*;
import java.text.*;
public class LCAP {
public static void Ley() {
System.out.printf("Evaluacion segun la LCAP:\n\n"+
"Articulo 85. Criterios para apreciar las ofertas desproporcionadas o temerarias en las\n"+
"subastas.- Se consideraran, en principio, desproporcionadas o temerarias las ofertas que\n"+