lauhin
lauhin
Reputation Top 1%
Laurent Hinoul
18 Snippets
Published
1 Channel
Created
13 Channels
Following
866 points
Reputation
Top 10% Publisher
Junior Code Generator
Serious Code Generator
Senior Code Generator
Junior Publisher
Serious Publisher
Senior Publisher
Junior Topic Hub
Junior Trend Maker
Junior Popular Coder
Serious Popular Coder
Senior Popular Coder
Junior Autobiographer
Serious Autobiographer
Senior Autobiographer
Master Autobiographer
Junior Snip2Coder
Senior Famous Coder
Junior Wise Coder

Recent Snippets See all snippets by lauhin

public by  5371  3  7  1

Count chars in a String in Java

Count chars in Strings or letters in words in Java using the Spring framework
import org.springframework.util.StringUtils;

int occurance = StringUtils.countOccurrencesOf("012405802569015014", "0"); //returns 5
int occurance = StringUtils.countOccurrencesOf("hello world", "l"); //returns 3
;

public by lauhin  4616  11  5  0

Java date to String

this code converts a java date to a String
//this code converts a java date to a string
DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
String reportDate = df.format(today);
;

public by lauhin  2789  1  5  0

Find tables where certain columns exists

if you need to find all tables where a column name exists, you can search that with this query
//this query will give you all table names in a database where certain column names exists.
select distinct table_name
    from information_schema.columns
    where column_name in ('columnA','ColumnB')
        and table_schema = 'YourDatabase';            
;

public by lauhin  4904  1  5  0

Interator to stream in Java 8

makes a java 8 stream from an iterator
//this method converts a iterator to a stream. This can only be used in Java 8
public static <T> Stream<T> iteratorToStream(final Iterator<T> iterator, final boolean parallell) {
  Iterable<T> iterable = () -> iterator;
  return StreamSupport.stream(iterable.spliterator(), parallell);
}

//here I show you how to use this method. You need this try arround it so Java will close the stream automatically after using it.
try (Stream<???> stream = Utils.<???>iteratorToStream(anIterator, true)) {
  
}
;

public by lauhin  2076  0  3  0

How to update all outdated homebrew software.

How to update all outdated homebrew software.: update-homebrew
brew update && brew upgrade `brew outdated`

;