Skip to content

Instantly share code, notes, and snippets.

# Determine Java version of Jar
unzip -p file.jar | head
which node
#-->node: /usr/bin/node /usr/bin/X11/node /usr/local/bin/node /usr/share/man/man1/node.1.gz
which node | cut -d':' -f1
#-->node
which node | cut -d':' -f2
#--> /usr/bin/node /usr/bin/X11/node /usr/local/bin/node /usr/share/man/man1/node.1.gz
which node | cut -d':' -f3
# Edit Alias File
vi ~/.bash_profile
# Change terminal prompt
export PS1="$ "
@Test
public void testPaths()
{
Path currentDir = Paths.get("");
System.out.println(currentDir.toAbsolutePath().toString());
currentDir = Paths.get(".");
System.out.println(currentDir.toAbsolutePath().toString());
String dir = System.getProperty("user.dir");
import java.io.*;
import java.nio.file.*;
import java.nio.file.attribute.*;
import static java.nio.file.FileVisitResult.*;
import static java.nio.file.FileVisitOption.*;
import java.util.*;
public class FileFinder {
package com.dsths.pmab.resources.batch;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.xml.bind.annotation.adapters.XmlAdapter;
public class MapAdapterX extends XmlAdapter<MapAdapterX.MapElements, Map<String, String>>
@theobriscoe
theobriscoe / java-8-stream-filtering-example.java
Last active January 24, 2016 23:44
Java 8 Streams API Filtering example
List<String> wordList =
Arrays.asList("apple", "banana", "cantaloupe", "date", "elderberry");
List<String> newWordList = wordList
.stream()
.filter(word -> word.startsWith("c"))
.map(String::toUpperCase)
.sorted()
.collect(toList());
@theobriscoe
theobriscoe / learning-maven-01.xml
Created January 17, 2016 15:44
Upgrading JUnit
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
@theobriscoe
theobriscoe / gist:8152195
Created December 27, 2013 20:28
JAXB to String
private void toXML(Product product) {
JAXBContext jaxbContext;
try {
jaxbContext = JAXBContext.newInstance(Product.class);
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
jaxbMarshaller.marshal(product, System.out);
}
catch (JAXBException e) {
@theobriscoe
theobriscoe / getFileAsString
Last active August 14, 2016 16:06
Loading a file as a String in Java
package com.theobriscoe.example.utils;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;