Skip to content

Instantly share code, notes, and snippets.

List<String> stringList = Arrays.asList("a", "b", "c", "ddd");
int result = stringList.stream().reduce(0, (acc, element ) -> acc + element.length(),(c1, c2) -> c1 + c2);
@mlevvy
mlevvy / GroovySpreadOperatorTest.groovy
Created November 26, 2015 08:26
Problem with @CompileStatic, SpreadOperator and calling a function
package pl.klkl
import groovy.transform.CompileStatic
import spock.lang.Specification
class GroovySpreadOperatorTest extends Specification {
interface Service {
List<Integer> heavyOperation()
}
@mlevvy
mlevvy / feedback.sql
Created November 1, 2015 17:40
Feedback queries
create or replace view feedback_mentor as
with mentor_rating as (select
mentor_id,
count(fe.mentor_id) as RATING_COUNT,
avg(fe.answer::integer) as AVG_SCORE,
string_agg(fe.answer , ',') as SCORES,
string_agg('"' || fe.comment || '"' , ';') as COMMENTS
from
feedback fe
where