Skip to content

Instantly share code, notes, and snippets.

@davidraviv
davidraviv / HTTPMessage.java
Created May 22, 2014 08:45
Simple HTTP sender using java.net
package com.x.proxy.http;
import java.io.Serializable;
import java.util.Map;
/**
* Created by davidraviv on 7/5/14.
*/
public class HTTPMessage implements Serializable {
public String url;
@davidraviv
davidraviv / PrintLogoToConsole.java
Created May 19, 2014 12:52
From http://stackoverflow.com/questions/3886201/java-outputting-text-file-to-console Print the content of a text file to the console. I used it to print a logo.
try {
// draw logo to console
InputStream input = new BufferedInputStream(new FileInputStream("src/main/resources/logo.txt"));
byte[] buffer = new byte[8192];
try {
for (int length = 0; (length = input.read(buffer)) != -1;) {
System.out.write(buffer, 0, length);
}
} finally {
@davidraviv
davidraviv / 0_reuse_code.js
Created May 19, 2014 12:43
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@davidraviv
davidraviv / ActionFactory.java
Last active August 29, 2015 14:01
Simple singleton factory to create class implementing Action interface.The constructor for creating the class is cached internally to reuse in the next invokation.In the className implementation is missing, this factory returns null.* Action is proprietary interface, can be replaced with any other interface. JsonNode is the constructor input for…
package com.company.product
import com.fasterxml.jackson.databind.JsonNode;
import org.apache.log4j.Logger;
import java.lang.reflect.Constructor;
import java.util.HashMap;
import java.util.Map;
/**
@davidraviv
davidraviv / generate_wsdl_pom.xml
Created April 17, 2014 13:42
Add this to the build part of a pom.xml to generate wsdl related classes. The wsdl is expected to be locally stored under src/main/resources/wsdl
<build>
<plugins>
<!--Generate wsdl related classes-->
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
@davidraviv
davidraviv / scala_complie_package_pom.xml
Created March 27, 2014 15:51
Compile and package a scala code to a single jar. Also includes dependencies for json4s that can be omitted.
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.wm</groupId>
<artifactId>wmLogger</artifactId>
<version>1.0-SNAPSHOT</version>
@davidraviv
davidraviv / basic_scala_pom.xml
Created March 27, 2014 12:41
Basic maven pom.xml that allows building a scala project. No need to prior install scala.
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.wm</groupId>
<artifactId>wmLogger</artifactId>
<version>1.0-SNAPSHOT</version>