Skip to content

Instantly share code, notes, and snippets.

@dfparker2002
dfparker2002 / JoinerTest.java
Created June 26, 2016 23:37 — forked from K0NRAD/JoinerTest.java
guava joiner examples
@Test
public void testJoiner() throws Exception {
List<String> texts = Lists.newArrayList("eins", null, "drei", "vier", "fünf", "sechs", "sieben", null);
String joined;
String expected;
joined = Joiner.on(";")
.skipNulls()
.join(texts);
@dfparker2002
dfparker2002 / mapsplitter.java
Created June 26, 2016 23:37 — forked from dtulig/mapsplitter.java
Example of using Guava's MapSplitter
final String stringToSplit = "dave:123, john:314,, matt:989";
final Map<String, String> splitKeyValues = Splitter.on(",")
.omitEmptyStrings()
.trimResults()
.withKeyValueSeparator(":")
.split(stringToSplit);
// Map Contents: {dave=123, john=314, matt=989}
@dfparker2002
dfparker2002 / .gitignore
Created July 5, 2016 17:21 — forked from octocat/.gitignore
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
/*
* adapted from example @ http://stackoverflow.com/questions/2723397/what-is-pecs-producer-extends-consumer-super/2723538#2723538
* Get And Put Principle (From Java Generics and Collections)
*
* It states,
* use an extends wildcard when you only get values out of a structure
* use a super wildcard when you only put values into a structure
* **** and don’t use a wildcard when you both get and put. ***
*
*/
@dfparker2002
dfparker2002 / LuceneJcr.java
Created August 31, 2016 14:13 — forked from chetanmeh/LuceneJcr.java
Oak Lucene Index Example
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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
@dfparker2002
dfparker2002 / RadixSort.java
Created September 6, 2016 09:42 — forked from yeison/RadixSort.java
Implementation of Radix Sort in Java.
/*
RadixSort.java : Sorts 32-bit integers with O(n*k) runtime performance.
Where k is the max number of digits of the numbers being
sorted.
(i.e. k=10 digits for 32-bit integers.)
Copyright (C) 2013 Yeison Rodriguez ( github.com/yeison )
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
package counting.sort;
public class CountingSort
{
public static int maximumElement( Integer array[] )
{
// Set the largest element to the first for comparison
int max;
max = array[ 1 ];
public class BinarySearch {
// Find first target in array
public int binarySearch(int[] arr, int target){
if (arr.length == 0){
return -1;
}
int start = 0 ;
int end = arr.length - 1;
int mid;
@dfparker2002
dfparker2002 / binary_search.js
Created September 6, 2016 09:46 — forked from mrsweaters/binary_search.js
Binary Search
var binary_search = function (list, item) {
var low = 0;
var high = list.length - 1;
while(low <= high) {
var mid = Math.floor((low + high) / 2);
var guess = list[mid];
if (guess === item) {
return mid;
} else if (guess > item) {
high = mid - 1;
@dfparker2002
dfparker2002 / nextLex.js
Created September 6, 2016 09:48 — forked from alexislagante/nextLex.js
Next String (using counting sort)
function nextLex(str) {
var breakIndex = -1;
var chars = str.split("");
for (var i=chars.length-1; i>0; i--) {
if (chars[i] > chars[i-1]) {
breakIndex = i-1;
break;
}
}