Skip to content

Instantly share code, notes, and snippets.

## the typo is that in line 7, we should add to newCollection.
## Intellij is able to reason that we only ever go through the loop once, and offset < 8 is always false
while (!collection.isEmpty() && offset < 8) {
var newCollection = new HashSet<>();
for (var x : collection) {
if (someCondition(x)) {
collection.add(derivedValue(x));
}
}
Benchmark (stringLength) (successPct) Mode Cnt Score Error Units
EmailBenchmark.testMyMatcher 16 .1 avgt 43.356 ns/op
EmailBenchmark.testMyMatcher 16 .5 avgt 85.844 ns/op
EmailBenchmark.testMyMatcher 16 .9 avgt 127.384 ns/op
EmailBenchmark.testMyMatcher 256 .1 avgt 232.553 ns/op
EmailBenchmark.testMyMatcher 256 .5 avgt 1234.144 ns/op
EmailBenchmark.testMyMatcher 256 .9 avgt 1826.578 ns/op
EmailBenchmark.testMyMatcher 4096 .1 avgt 3465.675 ns/op
EmailBenchmark.testMyMatcher 4096 .5 avgt 17361.246 ns/op
EmailBenchmark.testMyMatcher 4096 .9 avgt 33907.657 ns/op
package com.justinblank;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import java.util.concurrent.TimeUnit;
@Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
@Fork(3)
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
public class TestClass implements Serializable {
private TestClass testClass;
/**
* Represents a typed computation that may either return a result or a meaningful error
* @param <E> the type of errors that are tracked
* @param <V> the type of values that are computed
*/
public class Result<E, V> {
private final E error;
private final V value;
var date = Date.now();
var array = [];
for (var i = 0; i < 2000000; i++) {
array.push(Math.random());
}
console.log(Date.now() - date);
array.sort();
for (var j = 0; j< 5; j++) {
console.log(array[j]);
}
import java.util.Optional;
public class OptionalTest {
public OptionalTest() {
// TODO Auto-generated constructor stub
}
public static void main(String[] args) {
try {
@hyperpape
hyperpape / jsamples.j
Last active December 10, 2015 19:28
Nice little bits of mind-numbingness from the j labs (tutorials). Note that this isn't really Objective-J, but the j language invented by Kenneth Iverson (creator of APL). J is a nice mixture between interesting and insane. It's the true line noise language, and makes perl look readable by comparison.
x =: 3 5 $ 3 1 4 2
x * x
9 1 16 4 9
1 16 4 9 1
16 4 9 1 16
x +/ x
0 1 2 3 4 5 6 7 8
1 2 3 4 5 6 7 8 9
@hyperpape
hyperpape / manifest.json
Created September 14, 2012 20:10
Show/hide Hidden Text
{
"name": "Show/Hide Hidden Text",
"version": "1",
"manifest_version": 2,
"description": "Shows and hides all text hidden in hide tags.",
"content_scripts": [
{"matches" : ["http://lifein19x19.com/*",
"http://www.lifein19x19.com/*"],
"js": ["showhide.js"]
}