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 com.googlecode.totallylazy.Callable1; | |
import com.googlecode.totallylazy.Callable2; | |
public class Lenses { | |
public static void main(String[] args) throws Exception { | |
Person rhys = new Person("rhys", 33, new Address("2 east lane", new Postcode("se16", "4uq"))); | |
Person older_rhys = personAgeLens().set(rhys, 34); |
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
> db.runCommand({aggregate:"prod", pipeline:pipeline, explain:true}); | |
{ | |
"serverPipeline" : [ | |
{ | |
"query" : { | |
"_id" : { | |
"$gte" : 1346281200000 | |
} | |
}, | |
"projection" : { |
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
command: { aggregate: "activemq_berylcoral", pipeline: [ { $match: { _id: { $gte: 1346281200000 } } }, { $group: { _id: { $divide: [ "$_id", 86400000 ] }, aggregation: { $avg: "$jvmThreadCount" } } } ] } ntoreturn:1 keyUpdates:0 numYields: 1 locks(micros) r:2162903 reslen:246035 1379ms | |
command: { mapreduce: "activemq_berylcoral", map: "function() { emit(this._id - (this._id % 86400000), { aggregate:0, count:1, sum: this['jvmThreadCount'] } );}", reduce: " | |
function (name, values) { | |
var result = { aggregate:0, count:0, sum:0 }; | |
values.forEach(function(f) { | |
result.sum += f.sum; | |
...", verbose: false, out: { inline: true }, query: { _id: { $gte: 1346281200000 } }, finalize: " |
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
var m = function() { | |
emit(this._id - (this._id % 86400000), { aggregate:0, count:1, sum: this['threadCount'] } ); | |
}; | |
var r = function (name, values) { | |
var result = { aggregate:0, count:0, sum:0 }; | |
values.forEach(function(f) { | |
result.sum += f.sum; | |
result.count += f.count; | |
}); |
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
db.prod.aggregate( | |
{ $match : { _id: { $gte: someTimestamp }}}, | |
{ $group : | |
{ | |
_id : { $subtract: ["$_id", { $mod: ["$_id", 86400000] } ] } , | |
averagePerDay : { $avg : "$threadCount" } | |
} | |
} | |
) |
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 com.googlecode.totallylazy.Callable1; | |
import com.googlecode.totallylazy.Callers; | |
import static sky.sns.bumblebee.io.Regex.regex; | |
public abstract class Validation<E, A> { | |
public abstract <X> X fold(final Callable1<E, X> fail, Callable1<A, X> success); | |
public static <E, A> Validation<E, A> fail(final E e) { | |
return new Validation<E, A>() { |
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 com.googlecode.totallylazy.Option; | |
import com.googlecode.totallylazy.Sequences; | |
import org.junit.Test; | |
import static com.googlecode.totallylazy.Sequences.sequence; | |
import static org.hamcrest.CoreMatchers.equalTo; | |
import static org.hamcrest.CoreMatchers.is; | |
import static org.hamcrest.MatcherAssert.assertThat; | |
public class RegexTest { |
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 com.googlecode.totallylazy.Callable1; | |
import com.googlecode.totallylazy.Option; | |
import java.util.regex.Matcher; | |
import java.util.regex.Pattern; | |
import static com.googlecode.totallylazy.Option.none; | |
import static com.googlecode.totallylazy.Option.some; | |
import static com.googlecode.totallylazy.numbers.Numbers.range; |
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
private void attachListener() { | |
ScheduledFuture<?> activemqWarning = scheduleWarningIfJmsConnectionTakesTooLong(); | |
try { | |
// perform some operation that may hang if ActiveMq is not running | |
} finally { | |
activemqWarning.cancel(true); | |
} | |
} | |
private ScheduledFuture<?> scheduleWarningIfJmsConnectionTakesTooLong() { |
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
#!/usr/bin/env ruby | |
require 'fileutils' | |
require 'rexml/document' | |
class IntellijIml | |
def initialize(iml_file) | |
@iml_file = iml_file |