jbanana: Badly drawn banana (Default)
Java's no-frills debugger, jdb, takes debugging input from stdin. But if you're debugging something that gets user input from stdin, it won't ever get any input. So you start the thing you're debugging in another window, telling it to wait for the debugger, then attach the debugger. The incantation for this is verbose and I always have to look it up, so here it is to help me next time.
cmd /c start java -Xrunjdwp:transport=dt_socket,address=5005,server=y,suspend=y SomeJavaClass
jdb -connect com.sun.jdi.SocketAttach:hostname=localhost,port=5005
I also have a regular set of stuff to put in jdb.ini to make jdb less painful.
stop at SomeJavaClass:57
exclude java.*,javax.*,sun.*,com.sun.*,junit.*,jdk.*
run
monitor locals
monitor list
jbanana: Badly drawn banana (Default)
I installed a VM with Alpine Linux. It uses BusyBox, including for the default shell, ash. How do I set an alias?

I tried startup scripts of various names. No joy. They were ignored. The internet suggested that if I put the name of the script in an environment variable called ENV, the named script would be run at shell startup. But where do I set *that*?

After poking around, all scripts in /etc/profile.d get run, so I added /etc/profile.d/setashrc.sh which just contains
export ENV=$HOME/.ashrc

Now I can set an alias in ~/.ashrc but I'm wondering why there isn't some sort of default?

Anyway, this post is mostly in case I ever need to do this again.
jbanana: Badly drawn banana (Default)
I just had an idea. When you get unsolicited email then it might get spam filtered, or you might delete it without even reading. But what if you could request that the email bounces? It should work exactly as if the sender go the address wrong, so it would appear that you don't exist.

No idea if that would be hard to implement, or break email in some unexpected way. And the down side is that a lot of the dross won't have a sensible return address, but the marketing drones who send me stuff at work do have a return address. And I hate them.
jbanana: Badly drawn banana (Default)
I added drag/drop to open a local file; fixed gopher search; added copying a link URL; allowed user to accept expired/changed certificates; fixed a bunch of little bugs.

I find that I'm reading the news more because I can get it without all the bloat of the web.

I've also found that web browsers now have "reader view" that gets you a Gemini aesthetic: clear fonts, plain text, and no distractions. I recommend that if you haven't tried it. Firefox, Safari and Vivaldi have it built in. Chrome and Edge have extensions that will do it.

Feature possibilities: visited link colour; tabs; feed subscription; persistent history; public release (!)
jbanana: Badly drawn banana (Default)
I said...
I'll try to stop tinkering with it now.
...which didn't go as planned.

I fixed a bunch of bugs with socket timeouts, certificate names and URL handling. I added "find in page" and "search geminispace". I allowed a URL parameter at start up. And I figured how to make gemini:// links work from a browser (icky registry hack).

And I set up a gemini capsule at gemini://freeshell.de/ (I can click that link!)

Bug list: [tumbleweed]
Feature requests: visited link colour; tabs?
jbanana: Badly drawn banana (Default)
I fixed all the things I broke, and Gopher now works. There's a surprisingly large amount of Gopher content.

I'll try to stop tinkering with it now. I guess I really should put some effort into a public release...

Bug list: [tumbleweed]
Feature requests: visited link colour; tabs?
jbanana: Badly drawn banana (Default)
I wanted Jemi to support Gopher as well as Gemini. This was hard because the code was a plate of spaghetti. The protocol handling, the Gemini text rendering and the UI handling were entangled with one another. So I broke everything and put it back in more sane layers. So now I have... lasagne?

I also have previously-working features that are now broken. Sigh. Should be easy enough to fix, I hope.

Well, bookmarks are working.

Bug list: broken external links (http[s], mailto); broken image rendering; history dialog shows URLs; view source toggle back to front; local files don't display; links not showing in status bar on mouseover
Feature requests: visited link colour; gopher protocol; tabs?
jbanana: Badly drawn banana (Default)
I was always puzzled by something in the File class. It has getAbsolutePath() and getCanonicalPath() and they both do almost the same thing: return a fully qualified name of the file. One difference is that the "absolute" version doesn't simplify paths with ".." which makes the "canonical" version always looks tempting. But that version throws IOException, so you need a try block, which makes it a pain.

How could cleaning up a file path cause an IOException? Documentation says "construction of the canonical pathname may require filesystem queries" and I've never known what that could mean.

Today I passed a ridiculously long name to the "canonical" version and it said IOException: The parameter is incorrect. Shortening the name made it work. I think it's telling me "that file cannot possibly exist on this file system", which kind-of fits into the "filesystem queries" category mentioned in the docs.
jbanana: Badly drawn banana (Default)
I fixed stuff - links to the regular web work, as do images (but doesn't deal with big images well)

At some point I might try a public release. But that would require pushing Compositor to maven central and/or getting my head round modules.

If you want to try it now, you'd need git and maven, then
git clone https://git.code.sf.net/p/compositor/code compositor
cd compositor
mvn package
java -classpath core\target\compositor-1.0-SNAPSHOT.jar;apps\target\apps-1.0-SNAPSHOT.jar net.sf.compositor.gemini.Jemi
...and who has the patience for that?

Bug list: mailto links (I found one!)
Feature requests: bookmarks; visited link colour; gopher protocol; tabs?
jbanana: Badly drawn banana (Default)
It's lovely reading stuff on Gemini. There's no ads, no images, no "design", no cookies or other tracking, just... words. It's really calm. This works fine for reading ordinary people's content - blogs, etc. It doesn't seem to work for, say, a news organisation because they can't get paid for what they're doing.

Anyway, I fixed a bunch of things in Jemi: wait cursor after clicking a link; context menu; user-defined colours; keyboard scrolling; protocol error handling.

Bug list: not handling external links (HTTP, etc); non-text responses... should what?
Feature requests: bookmarks; visited link colour; gopher protocol
jbanana: Badly drawn banana (Default)
I felt pretty awful after my Covid vaccination, so I spent a lot of time sitting in bed working on Jemi.

I added handling for all the error responses; view source; user-selectable font; remember size, position and zoom; fixed link bugs (I think); fixed reading badly formatted response headers; fixed the default page so it's gemini text and in the history; fixed cache bug (nothing ever timed out)

Bug list: no wait cursor after clicking a link; not handling external links (HTTP, etc); non-text responses... should what? (hmm - some other clients allow you to display an image link in line...)
Feature requests: bookmarks; context menu; visited link colour; user-defined colours; gopher protocol, because it's a piece of cake
jbanana: Badly drawn banana (Default)
I fixed the history - a working back button is a big win. I fixed the location bar.

Bug list: no wait cursor after clicking a link; relative links sometimes go to wrong place (or do they?); links with a port number don't work right; not handling external links - HTTP, etc; non-text responses... should what?
Feature requests: bookmarks; cope with badly formatted response header (quite a few of those - gives server authors a hard stare); history; context menu; visited link colour; user-defined colours, fonts, etc Edit: gopher protocol, because it's a piece of cake
jbanana: Badly drawn banana (Default)
I'd only ever seen train track diagrams for SQL. They're a good way of showing how the syntax works rather than describing it. Turns out you can do that with regex too.

I wrote a regex to parse garbage collection logs:
(?:[-0-9.T:+]+: )?([0-9.]+): \[((?:Full )?GC(?:--|AdaptiveSizePolicy::compute_survivor_space_size_and_thresh:)? ?(?:\((?:System|Ergonomics)\)(?:AdaptiveSizeStart:)? )?(?:[0-9.]+: )?(?:[0-9.]+: )?).*?(?:\[(?:DefNew(?: \(promotion failed\) )?|PSYoungGen): ([0-9]+)K->([0-9]+)K\(([0-9]+)K\)(?:, [0-9.]+ secs)?\])?(?:[0-9.]+:)?(?: )?(?:\[(?:Tenured|PSOldGen|ParOldGen): ([0-9]+)K->([0-9]+)K\(([0-9]+)K\)(?:, [0-9.]+ secs)?\])? ?([0-9]+)K->([0-9]+)K\(([0-9]+)K\),? (?:\[(?:Perm|PSPermGen|Metaspace) ?: ([0-9]+)K->([0-9]+)K\(([0-9]+)K\)\], )?([0-9.]+) secs\](?:.*?)?
Good luck working out what that does, unless you turn it into train tracks.

And here's a regex that matches numbers divisible by 3:
([0369]|[147][0369]*[258]|(([258]|[147][0369]*[147])([0369]|[258][0369]*[147])*([147]|[258][0369]*[258])))+
source
First, it seems that you can match numbers divisible by anything (!) in regex. And second, I'm not sure it helps that much to make a divisible-by-3 train track diagram. I'm thinking "why does that work?" and at the same time "Please don't explain".
jbanana: Badly drawn banana (Default)
I fixed zooming the text because it was infuriating to have tiny text all the time. I added a cache. I've got to the point where I can actually use Jemi to read content in Gemini space and only several aspects are broken (not all aspects). It was frustrating that it didn't work at all. Now it's frustrating because it almost works.

Bug list: relative links sometimes go to wrong place; not handling external links - HTTP, etc; back button... doesn't; location bar doesn't work; non-text responses... should what?
jbanana: Badly drawn banana (Default)
I fixed a bunch of issues with relative URLs, and I'm now reading the response status and mime type correctly. I don't cope too well if it's not 20 text/gemini, but at least I have the right info so I can implement more. Redirects (3x someUrl) should definite work, and so should user input (1x).

Styling is better - fonts, padding sorted and headings work right.

And the client is called Jemi.

Bug list: preformatted text... isn't; not handling external links - HTTP, etc; back button... doesn't; location bar doesn't work; non-20 responses shouldn't all be treated as errors; non-text responses... should what?

Gemini

Mar. 11th, 2021 01:05 pm
jbanana: Badly drawn banana (Default)
I stumbled upon the Gemini protocol. I've no idea if it will be a success, but it seems like a nice idea. And it's not too hard to write a client, so I've been doing that.

I already have a thing for making a GUI. Rendering a page with links just means putting some HTML into JEditorPane and adding a HyperlinkListener, so I just have to fetch a page and translate it. There was some fun and games with the TLS/TOFU requirement, but I asked the internet and got a sensible answer.

Bug list: preformatted text... isn't; all responses assumed text/gemini - whoops; not handling external links - HTTP, etc; back button... doesn't; general styling yuckiness
jbanana: Badly drawn banana (Default)
Maven is a the big thing in Java build tools. At one time it was Ant, and now some people use Gradle. My view would be to use anything but Maven because there are so many things about it that are annoying and stupid. Today I came rediscovered one such thing.

Maven wants you to put things in certain places, and it wants you to define a bunch of stuff in pom.xml, and I knew that for a new project Maven has archetypes as a way of setting up some of that boilerplate. Hmm, what's the syntax for that? I guessed a couple of times and it didn't work. A bit of searching found me a simple archetype which does the bare minimum - sounds like what I want. But the syntax to do that is
mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-simple -DarchetypeVersion=1.4
WTF?

Edit: subsidiary rant - this simple archetype generates 81 lines of xml. WTF?
jbanana: Badly drawn banana (Default)
Two things that make me want to yell at someone: "cannot find the file specified" and "cannot connect to remote server".

It's telling me that it didn't work. But what's the name of the thing it couldn't find? Someone's thought about error handling, but missed out the most important part: the name of the thing that didn't work.

I wasted most of yesterday because the thing it couldn't find wasn't pathInConfigFile but subdirectoryOfPathInConfigFile.
jbanana: Badly drawn banana (Default)
In bash, I want to delete a lot of files. Easy enough:
rm somepath/prefix*.txt
But I get "Argument list too long" because there are a *lot* of files. Well, I know I can use find like this:
find somepath -name "prefix*.txt" -exec rm '{}' \;
but that removes the files one at a time, and there are thousands of them so it's inefficient (and I'm impatient).

Solution:
find somepath -name "prefix*.txt" -print0 | xargs -0 rm
Nice - the output from find is collected up by xargs until it has a nice big list but not too big and then it executes rm on that list, and repeats until none left.

Now I can't see what was baffling me.
jbanana: Badly drawn banana (Default)
I don't know what it should really be called, but I had to do a "cross outer join" for the first time in an SQL query.
select
    coalesce(preferredValue, fallbackValue) as combined
from
    (
        select fallbackValue
        from someTable
        where someCondition
    ) a
    left join (
        select preferredValue
        from otherTable
        where otherCondition
    ) b on 1=1
This works if the second subquery returns either what you want or nothing at all. The coalesce only returns fallbackValue if the second subquery returns nothing.

The 1=1 part makes this work, but it also makes me queasy because I came across it reading about SQL injection attacks.
Page generated Jul. 5th, 2025 06:05 am
Powered by Dreamwidth Studios