Sunday, December 15, 2019

blog.zmeeagain.com no more

This is probably the last post in this blog. I've decided to put any new posts on a markdown-based static site, at blog.zmeeaga.in.

Sunday, October 27, 2019

old proxy tunneling issue with java

So you happen to work in an environment where you're behind a proxy. Not a big deal you might think, a bit annoying, yes. Until the moment when you run e.g. the gradle wrapper and hits you back with
a
Exception in thread "main" java.io.IOException: Unable to tunnel through proxy. Proxy returns "HTTP/1.1 407 Proxy Authentication Required"
exception. But surely you have configured everything correctly, including the proxy authentication. You never had this before, but then again you were never before behind an authenticated proxy. You run curl against the same gradle.org address to get the distribution with those exact proxy settings and it just works!

There's a simple explanation for that: since jdk8u111 Basic authentication for https tunneling is not allowed. To override this for gradle you may pass systemProp.jdk.http.auth.tunneling.disabledSchemes="" to gradle.properties. More generally you can pass/configure jdk.http.auth.tunneling.disabledSchemes jvm property to empty or remove Basic if already there, or do it globally in net.properties of jre/lib.

Monday, October 21, 2019

random ids in idea

Stop entering ad-hoc magic constants or 1,2,3,... sequences in your intent request codes, or build scripts to generate random translation keys. Embrace randomness and just use groovy scripts directly in IntelliJ live templates. A random positive integer might simply be $RANDOM$=groovyScript("new Random().nextInt() & Integer.MAX_VALUE"), a short $RANDOM$=groovyScript("new Random().nextInt(65535) + 1"), and a fixed 7-digit, 0-padded number $RANDOM$=groovyScript("String.format(\"%07d\", new Random().nextInt(999999))"). The definition for the latter would be:

<template name="rnd7p0" value="$RANDOM$" description="Generate a random number up to 7 digits, left padded with 0s if needed." toReformat="false" toShortenFQNames="true">
    <variable name="RANDOM" expression="groovyScript(&quot;String.format(\&quot;%07d\&quot;, new Random().nextInt(999999))&quot;)" defaultValue="" alwaysStopAt="false" />
    <context>
      <option name="OTHER" value="true" />
    </context>
  </template>


Or, you can install the randomness plugin.

Friday, June 21, 2019

comments formatting

Some people argue that if you do not intend to produce javadoc for your project, you should not clutter your comments with unnecessary <pre>s, <blockquote>s and the likes. I tend to disagree. The reason? Ctrl+Q.