HNHacker News
TopNewBestAskShowJobs

sedro

77 karma · joined April 21, 2016

submissionscomments
sedro··on Rating 26 years of Java changes
That's another gotcha-- interning of strings and boxed primitives.

Are there linters for this sort of thing? I don't write Java much any more.

sedro··on Rating 26 years of Java changes
Autoboxing's evil twin, auto-unboxing should knock the score down a few points.

  Integer a = null;
  int b = 42;
  if (a == b) {} // throws NullPointerException
sedro··on A better (than Optional) maybe for Java
It's useful and very common to use. For example, you could concatenate together command-line argument flags that may or may not be present.
sedro··on Sol-Ark manufacturer reportedly disables all Deye inverters in the US
A separate VLAN, if your router is capable
sedro··on I built an online PDF management platform using open-source software
The PDF metadata says it's PyPDF2
sedro··on How to Use the Foreign Function API in Java 22 to Call C Libraries
It does! Code is here https://github.com/java-native-access/jna/blob/40f0a1249b5ad...
sedro··on How to Use the Foreign Function API in Java 22 to Call C Libraries
That's how java.io.File#deleteOnExit works under the hood. The DLL is still loaded at that point and can't be deleted.
sedro··on How to Use the Foreign Function API in Java 22 to Call C Libraries
According to JNA it's not safe to unload the DLL:

https://github.com/java-native-access/jna/blob/40f0a1249b5ad...

  Do NOT force the class loader to unload the native library, since
  that introduces issues with cleaning up any extant JNA bits
  (e.g. Memory) which may still need use of the library before shutdown.
Following the blame back to 2011, they did unload DLLs before https://github.com/java-native-access/jna/commit/71de662675b...

  Remove any automatically unpacked native library.  Forcing the class
  loader to unload it first is only required on Windows, since the
  temporary native library is still "in use" and can't be deleted until
  the native library is removed from its class loader.  Any deferred
  execution we might install at this point would prevent the Native
  class and its class loader from being GC'd, so we instead force 
  the native library unload just a little bit prematurely.
Users reported occasional access violation errors during shutdown.
sedro··on How to Use the Foreign Function API in Java 22 to Call C Libraries
You would also need to learn about Maven profiles and activation. And for other build tools, you'll be delighted to know they have partial support.
sedro··on How to Use the Foreign Function API in Java 22 to Call C Libraries
This wouldn't work on Windows, because you can't delete a DLL while it's in use
sedro··on How to Use the Foreign Function API in Java 22 to Call C Libraries
Native libraries are typically packaged inside a jar so that everything works over the existing build and dependency management systems.

For example, each these jars named "native-$os-$arch.jar" contain a .dll/.so/.dylib: https://repo1.maven.org/maven2/com/aayushatharva/brotli4j/

JNA will extract the appropriate native library (using os.name and os.arch system properties), save the library to a temp file, then load it.

sedro··on What if null was an Object in Java?
> I can't think of another statically typed language that screws this up so badly. It just keeps getting worse with stuff like Optional and @NotNull.

Java might be the only language where a simple assignment `x = y` can throw a NullPointerException (due to auto-unboxing)

sedro··on Java JEP 461: Stream Gatherers
Or more succinctly

  val num = words.count(_.nonEmpty)
sedro··on TypeScript NPM Packages Done Right
This cheatsheet would have you publish dist/*.{js,d.ts}. Presumably you would use "files":["dist"] in package.json to exclude sources from being published.

The OP recommends to additionally package src/*.ts along with sourceMaps and declarationMaps.

What's actually the best practice here?

sedro··on Internet-connected cars fail privacy and security tests conducted by Mozilla
California Code Regulations, title 10, Section 2632.5 - Rating Factors

It carves out an exception for "using a technological device to collect information about the location of the insured vehicle as part of an emergency road service, theft service, map service or travel service."

sedro··on Internet-connected cars fail privacy and security tests conducted by Mozilla
It's the same in parts of the US. In California, insurers are only allowed to collect the mileage.
sedro··on How to stay safe and happy on an electric unicycle
Maybe a foldable e-bike would be a good compromise?
sedro··on Things that improved between Elasticsearch 1 and 7
You can use G1 on Java 8 with -XX:+UseG1GC
sedro··on Retrofitting null-safety onto Java at Meta
You can use ?. or assign to a nullable type. Or you can get a NPE at runtime. Which is to say, it's not null-safe.
sedro··on Retrofitting null-safety onto Java at Meta
Kotlin interops nicely with Java but it's not null-safe (all references from Java are assumed non-null).
sedro··on You Hated Your Cable Package. Your Streaming Services Are Bringing It Back
This seems to work:

  document.querySelectorAll('video').forEach(v => v.playbackRate = 1.5)
sedro··on TypeScript is terrible for library developers
And the purpose of "T extends string" is to carry the value of a string literal. For example, there's the string value "foo", but there's also a type "foo" which extends string and has only the one possible value.
sedro··on Electronics are built with death dates. Let’s not keep them a secret
There's a mechanism: if people want their bulbs to match, they might pick the same brand/model as a replacement
sedro··on Favor real dependencies for unit testing
now you have N+2 problems?
sedro··on You don't need that CORS request
Are you conflating CORS with some specific product?
sedro··on We check our node_modules folder into source control
> Pinned versions don't mean anything when sub-dependencies can have transient versioning resolution occur.

That's the purpose of lockfiles-- to pin the entire dependency tree.

sedro··on I work on code search at GitHub – what needs to improve?
When I search for an identifier it comes up with usages, tests, docs, etc. I have to dig several pages to find the declaration/definition.
sedro··on LAPD arrests man on suspicion of making deadly swatting call to Wichita police
To clarify, the arrested individual sells a swatting "service" [1]. One of the CoD players hired him to swat the other over a twitter argument. The other CoD player taunted the swatter and gave him a random address [2]. The police showed up at the address and killed an unrelated person.

No parties involved are without blame.

[1] http://archive.is/Ixezf#selection-6279.0-6288.0 [2] https://i.imgur.com/n3Q53nL.png

sedro··on The fifth hyperfactorial: 5⁵ × 4⁴ × 3³ × 2² × 1¹ milliseconds is exactly 1 day
Look closely. Or, equivalently

  > n=12345678910111210
  > n+1 === n+2
  true
sedro··on Learn Kotlin in Y Minutes
Kotlin has its own standard library
Page 1 of 2Next →