This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String mkString(Iterable<?> values, String start, String sep, String end){ | |
// if the array is null or empty return an empty string | |
if(values == null || !values.iterator().hasNext()) | |
return ""; | |
// move all non-empty values from the original array to a new list (empty is a null, empty or all-whitespace string) | |
List<String> nonEmptyVals = new LinkedList<String>(); | |
for (Object val : values) { | |
if(val != null && val.toString().trim().length() > 0){ | |
nonEmptyVals.add(val.toString()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.springframework.context.ApplicationContext; | |
public class AppContext { | |
private static ApplicationContext context; | |
public static void setApplicationContext(ApplicationContext applicationContext) { | |
context = applicationContext; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function unescapeSpecialChars(str){ | |
var result = str; | |
var pattern = /\&#\d{1,4};/g; | |
var arrMatch = null; | |
while (arrMatch = pattern.exec( str )){ | |
result = result.replace(arrMatch[0], String.fromCharCode(/\&#(\d{1,4});/.exec(arrMatch[0])[1])); | |
} | |
return result; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#reload core | |
curl {server-name}/admin/cores -H "Content-Type: text/xml" -d "action=RELOAD" -d "core={core-name}" -G | |
#empty core | |
curl {server-name}/{core-name}/update -H "Content-Type: text/xml" --data-binary '<delete><query>*:*</query></delete>' | |
curl {server-name}/{core-name}/update -H "Content-Type: text/xml" --data-binary '<commit />' | |
curl {server-name}/{core-name}/update -H "Content-Type: text/xml" --data-binary '<optimize />' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class EscapeSpecialChars { | |
public static final char HEXA = 'H'; | |
public static final char DECIMAL = 'D'; | |
private int minRange; | |
private int maxRange; | |
private String prefixEscape; | |
private String suffixEscape; | |
private String exclusionCharList; | |
private char formatMethod; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def extractNonEmptyTextChilds(n: Node): String = n map { e => e.child.filter({f => f.text.trim() != "" && f.label == "#PCDATA"}) text } mkString |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object ElvisOP { | |
implicit def any2elvis(x: Any) = new ElvisOP(Option(x)) | |
} | |
class ElvisOP(me: Option[Any]) { | |
def ?> (that: Any) = me match{ | |
case Some(s: String) => s match { | |
case _ if s.isEmpty() => that | |
case _ => s | |
} | |
case Some(b: Boolean) => if(!b) that else b |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static <A, B> Iterable<Pair<A, B>> zipAll(Iterable<A> iter1, Iterable<B> iter2, A def1, B def2){ | |
List<Pair<A, B>> zipped = new ArrayList<TitleParser.Pair<A,B>>(); | |
Iterator<A> these = iter1.iterator(); | |
Iterator<B> those = iter2.iterator(); | |
while(these.hasNext() && those.hasNext()){ | |
zipped.add(new Pair<A, B>(these.next(), those.next())); | |
} | |
while(these.hasNext()){ | |
zipped.add(new Pair<A, B>(these.next(), def2)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.caoticode.spring.interceptors.conditional; | |
import javax.servlet.http.HttpServletRequest; | |
import org.springframework.context.ApplicationContext; | |
public interface AccessCondition { | |
boolean test(HttpServletRequest request, ApplicationContext context); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.text.ParseException; | |
import java.text.SimpleDateFormat; | |
public final class DateConverter { | |
private SimpleDateFormat formatterFrom; | |
private SimpleDateFormat formatterTo; | |
private DateConverter(){ | |
super(); | |
} |
OlderNewer