Browsed by
Category: Technology

What state produces the most Professional Athletes?

What state produces the most Professional Athletes?

Have you ever been in conversation or on social media and heard someone claiming this state or that state has the best athletes. I definitely remember this as a little kid going to Five Star basketball camp each kid repping their state and throwing out this ballers name or that ballers name from their city or state. I decided to dig into this topic a bit and figure out which state in the U.S. really is king. In order to…

Read More Read More

How To Make a Custom NiFi Processor

How To Make a Custom NiFi Processor

I read a couple of forum posts(link1, link2) about converting CSV data to JSON with Apache NiFi. There are already solutions proposed for going from CSV to JSON in both of those links, one of which is writing your own Custom Processor. Since I already have code to convert data from CSV to JSON (see my post), I decided to write a NiFi Processor to accomplish the same thing. This blog entry will show how that was done. NiFi has a guide for developers reviewing several…

Read More Read More

Combining R and Java

Combining R and Java

Was curious if there were any libraries out there for combining R and Java so did some research to figure out the best library out there for this. Why? Since I know Java already combining it directly with R is something I was interested in. A use case could be if you have a mathematician who is great at using R to produce models but not so good at writing Java code to tie those models into your application. Combining…

Read More Read More

Jackson based JAX-RS Providers(JSON, XML, CSV) Example

Jackson based JAX-RS Providers(JSON, XML, CSV) Example

This blog post discusses returning multiple data formats from your RESTFul endpoints using Jackson JAX-RS providers. Jackson provides a lot of providers that you can see here . The providers allow you to return a POJO(plain old java object) from your REST annotated methods and give back the appropriate media type. Jackson also gives you the ability make your own Entity Providers. Documentation for how to do that is here below I’ll show a generic way to provide CSV’s along with XML…

Read More Read More

CXF Jetty Example

CXF Jetty Example

This is a simple example of how to combine CXF and Jetty to get a simple web services up and running. Pom for this example: [code language=”xml”] <?xml version="1.0"?> <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>datadidit.helpful.hints</groupId> <artifactId>parent</artifactId> <version>1.0.0-SNAPSHOT</version> </parent> <artifactId>jetty-cxf</artifactId> <name>jetty-cxf</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-frontend-jaxrs</artifactId> </dependency> <dependency> <groupId>javax.ws.rs</groupId> <artifactId>javax.ws.rs-api</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>${jetty.version}</version> </plugin> </plugins> </build> </project> [/code]   Here is a simple REST endpoint: [code language=”Java”] package datadidit.helpful.hints.rest.cxf; import javax.ws.rs.DefaultValue; import javax.ws.rs.GET; import…

Read More Read More

Enriching Datasets with R

Enriching Datasets with R

If you have a simple data set and have some additional statistics you’d like to add to that dataset you can easily do that with R. Going to add fip, woba, wrc, and wraa to a couple of baseball datasets as an example of this. To calculate FIP I first needed the following R functions: [code language=”r”] #Calculate FIP Constant fip_constant_calc <- function(pitching_data){ #FIP Constant = lgERA – (((13*lgHR)+(3*(lgBB+lgHBP))-(2*lgK))/lgIP) era = sum(pitching_data["ER"])/sum(pitching_data["IP"]) * 9 lgHR = sum(pitching_data["HR"]) lgBB = sum(pitching_data["BB"])…

Read More Read More

An Example CSV to Mongo Dataflow

An Example CSV to Mongo Dataflow

Do you have a bunch of CSV files laying around that you’d like to be able to run queries against? This post is going to discuss a way to do that with Apache Camel and a processor I wrote. Prerequisites: Ability to run a mvn camel:run A MongoDB installation available Technologies used: Apache Camel Maven MongoDB Wrote a Custom camel processor to take in a CSV file and turn it into JSON. Jackson was my tool of choice for converting…

Read More Read More

JSON to CSV with Jackson

JSON to CSV with Jackson

Needed to convert some JSON output to CSV this week on one of my REST endpoints. Previously on this endpoint I was using Gson to do the conversion. Gson does not natively support JSON to CSV conversion. So though I love how easy it is for me to type: [code language=”java”] Gson gson = new Gson(); gson.toJson("Hello World"); [/code] and easily retrtieve my Json. I switched over to using Jackson because it does support CSV conversion of my Pojos as…

Read More Read More

Hello Jersey and Jetty

Hello Jersey and Jetty

Seven Easy steps to get Jetty and Jersey working together When you need a servlet and don’t want to have to run your own web server like JBoss or Tomcat, Jetty is very handy. I like to use JAX-RS annotations and am very familiar with Jersey so I wanted to write a step by step tutorial for how to combine Jetty and Jersey. Instructions assume you know how to use Maven . 1. Use mvn archetype:generate to create your java…

Read More Read More

Mock Draft Stats

Mock Draft Stats

Every year the draft comes around and every year fans search the net to figure who they want their team to draft. As a Redskins fan I’m usually searching the net earlier than other teams fans and I’m pretty used to looking at Mock drafts. I usually look at Mock drafts to figure out who my team might draft and see if there’s hope that my favorite prospect might be available when my team picks. Instead of looking at a…

Read More Read More