Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View szegedi's full-sized avatar

Attila Szegedi szegedi

View GitHub Profile
import javax.script.*;
public class X {
public static void main(String[] args) throws ScriptException, NoSuchMethodException {
ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
ScriptEngine engine = scriptEngineManager.getEngineByName("nashorn");
Compilable ce = (Compilable) engine;
CompiledScript cs;
try {
String script = "function f1602838289254hw9b() {\n" +
@szegedi
szegedi / boolean-pattern.md
Last active October 4, 2018 16:43
Scala boolean pattern matching

TL;DR: scalac apparently doesn't believe in exhaustiveness of value set (true, false) for a boolean, so pattern matching on a boolean in Scala emits a branch for "neither true nor false". (I won't even go into it emitting comparison to 1 and 0 instead of using ifeq or ifne instructions, or those gotos that jump to the very next instruction.)

This scala code:

final class X {
  final def foo(b: Boolean) = 
    b match {
      case true  => 10
      case false => 11
    }

Keybase proof

I hereby claim:

  • I am szegedi on github.
  • I am asz (https://keybase.io/asz) on keybase.
  • I have a public key ASAFVgxsvW4XMH5ojizp_eBMIEX7iiRwCjz6ky6ki-k0Vwo

To claim this, I am signing this object:

@szegedi
szegedi / AszCA.txt
Created January 23, 2015 09:47
Attila Szegedi Contributor Agreement
Attila Szegedi Contributor Agreement
This Attila Szegedi Contributor Agreement (“ASzCA”) applies to any
contribution that you make to any product or project managed by me (the
“project”), and sets out the intellectual property rights you grant to
me in the contributed materials. The term “me” shall mean Attila
Szegedi, born on November 14, 1974 in Osijek, Croatia. The term “you”
shall mean the person or entity identified below. If you agree to be
bound by these terms, fill in the information requested below and sign
the ASzCA where indicated below. Read this agreement carefully before
@szegedi
szegedi / FunWithFloats.java
Created January 21, 2014 18:32
Fun with floats
import java.util.Objects;
public class FunWithFloats {
public static void main(String[] args) {
float f1 = 0.7f;
System.out.println(f1); // prints 0.7
double d = f1;
System.out.println(d); // prints 0.699999988079071
@szegedi
szegedi / memoryPoolsHotSpot
Created December 13, 2011 23:03
names of MemoryManagerMXBean and MemoryPoolMXBean instances in HotSpot JVM
Table of names of MemoryManagerMXBean and MemoryPoolMXBean instances under
different GC algorithms in Oracle HotSpot VM. Memory managers list the pools
they manage in square brackets; memory pools show their maximum sizes for -Xmx200M setting.
$ java -version
java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode)
SerialGC: