Dialog news

Aug. 6th, 2015 11:15 am
jbanana: Badly drawn banana (Default)
I accidentally discovered a wonderful thing. When you get a error dialog in Windows, you can copy a text-only version of the dialog by pressing the usual "copy" keyboard shortcut. You get something like this:
EditPlus 3
File operation failed.


The system cannot find the path specified.
It doesn't work for all dialogs, but when it does it's lovely.
jbanana: Badly drawn banana (Default)
I mentioned that I don't like Eclipse. There's more. Today I tried to run a test class: right click, "run as JUnit test". It said
Class not found [my test class]
java.lang.ClassNotFoundException: [my test class]
Er, you can't find the thing that I just clicked on. WTF?

Happily I found out how to run a single test with Maven:
mvn -Dtest=[my test class]#[my test method] test
jbanana: Badly drawn banana (Default)
Have you ever seen Scrapheap Challenge? Apparently it's called Junkyard Wars in the US.

It suddenly occurred to me today that writing software is a lot like that. There's an impossible time limit. You only get one go at doing it because the next build is something completely different. Most of the focus is on just making something that works. You spend a lot of time bolting together stuff that's already been made for some other purpose. And when it's time to show it to the world, it often breaks spectacularly.

Git notes

May. 21st, 2015 03:50 pm
jbanana: Badly drawn banana (Default)
"Oh dear, I messed up that commit. I know it can be undone. I'll google it (again)..."
As I write, that article has been viewed 2044004 times. About 5 of those were me.

What I was looking for every time is:
git reset --soft HEAD~1

I can't find a list of the most viewed questions, but I bet this one is on it.

RE fun

Jan. 31st, 2015 02:46 pm
jbanana: Badly drawn banana (Default)
I wanted to match filenames that don't end with .doc and I came up with [^.]*|.*\.(?!doc)[^.]*. Hmm, regexes are hard to read. Let's reformat...
(?x)    # comments and whitespace
[^.]*   # something with no dots
|       # ...or...
.*      # something...
\.      # ...with a dot...
(?!doc) # ...not followed by "doc"...
[^.]*   # ...but followed by soemthing with no dots
jbanana: Badly drawn banana (Default)
I've been writing Java code for 15 years (scary!) but there are still things to learn. Today I discovered you can't switch on a long, only an int. This is significant in the code I'm fixing because a certain type code is a long and we wouldn't want to be limited to Integer.MAX_VALUE types (2,147,483,647 of them)...

...except the actual number of types is 3.
jbanana: Badly drawn banana (Default)
Scary and dangerous as it is to mess with the registry, sometimes that's the only way.

I hate some of the fonts used by Windows, particularly Calibri. At large sizes it's ok, but at small sizes it goes grey and fuzzy. Eventually I got so fed up with it that I deleted it. Oops - a lot of Microsoft apps seem confused by missing fonts, and instead of another similar font, they use an icky script font. I was going to put Calibri back and admit defeat, but googling found me this:


...amd in case that page disappears, the registry fix is in
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontSubstitutes
jbanana: Badly drawn banana (Default)
This might help someone one day. I was trying to install Oracle. It kept failing, saying there was a problem checking the path.

"Cause:  Environment variable value could not be determined."
"Action:  Check user equivalence and whether the user has administrative privileges on the node."

The only way I could get it to run was by killing lots of other processes. I suspect that EMET was to blame, but I killed everything that I thought I could get away with.
jbanana: Badly drawn banana (Default)

TL/DR: to make tiny times understandable, make one CPU cycle a second and scale everything else accordingly. Memory access, 6 minutes - disk IO, months - reboot, millennia!
jbanana: Badly drawn banana (Default)
$ mkdir 'phone book'
$ rm 'phone book'
rm: cannot remove `phone book': Is a directory
jbanana: Badly drawn banana (Default)
git clone someSharedRepo
git checkout -b someNewBranch
# edit, commit, want to share the branch
git push -u origin someNewBranch

It's the -u what done it.

Edit Obvs this was a problem that lots of people had because now if you try to push to a remote branch that doesn't exist, git still fails, but helpfully suggests to you what you should do.
jbanana: Badly drawn banana (Default)
By combining Cygwin and some "new" for syntax, I can find tables inserted into by a huge script and generate queries to see how many rows there are now:
C:\sql> for /f %G in ('grep "insert into" load.sql ^| cut -d " " -f 3 ^| sort ^| uniq') do @echo select count(*) from %G;
If only the load script worked then there would have been some point to figuring that out.

And I say "new" in quotes because it changed at some time since I learned the "old" syntax twenty-something years ago...
jbanana: Badly drawn banana (Default)
It's unusual nowadays to have to deal with data in a non-text format. The only case I've had much experience with is Exif data in JPEGs, which I hacked at so I could display some photo metadata in Jix. The code I wrote then is pretty awful, partly because I couldn't be bothered to refactor it as it grew, but partly because parsing binary data is a pain. You have to tease out byte values into numbers and strings, paying attention to endian-ness, integer/floating point, signed/unsigned, explicit array lengths and pointers, all of which I'd left behind since I last wrote C in 1999.

Anyway, I was looking at the format of Java class files (just out of curiosity) and I tried writing a parser. It wasn't so hard, but the code soon began to look like the Exif mess. It occurred to me that some sort of generic parser might help. Then the work of reading binary data would be to document the format in some kind of binary description language for the parser to use...

But of course I'm not the first to think this: DFDL seems to be something like what I was thinking of, and Daffodil seems to be a Java implementation of it.

My only issue is that DFDL is horribly verbose. I had in mind something like assembler for binary data, but DFDL feels like Cobol translated into XML.


Edit: http://dilbert.com/strips/comic/2013-10-12/

NIO again

Jul. 15th, 2013 03:35 pm
jbanana: Badly drawn banana (Default)
Earlier this year I was pleased to find NIO tutorials. I've just been going over them again with a view to doing non-blocking IO on a server app, and I'm not happy! The tutorials are fine, but NIO makes life hard when what you really want is to read lines of characters, not arbitrary numbers of bytes. Googling finds lots of people asking how to do read lines, and lots of snotty answers along the lines of "Why are you using NIO, stupid?"

Side issue: when people ask a question, however stupid you think it is, don't be an arsehole in your answer, or if that's too hard, just don't answer.

Several people suggest that you could feed the bytes read in NIO into plain old IO streams, but that's WORK (and opportunity for bugs).


As I know and understand plain old IO and threads, I'll probably go with that. Shame.
jbanana: Badly drawn banana (Default)
Thanks, Beach Boys. Who knew you were enthusiasts for the dark corners of regular expression syntax?


I wondered what "zero-width positive lookahead" and friends were. Now I know.
jbanana: Badly drawn banana (Default)
Back in February I tried out Ubuntu. I didn't stick with it because I couldn't get the integration with our work Exchange server to work. Today was a quiet day, so I thought I'd try again. Hmm, what password did I use?

So, unless I have a sudden memory event, I'll be deleting that later. Ho hum.

The only reason that I tried it in the first place was Wubi, a Windows installer that Just Works. But I read that they've removed it in the latest release, so I'll probably never try Ubuntu again. This is sad. I find Windows annoying and frustrating, and although I'm familiar with its quirks, I'd like to use something that's less hassle. But installing, configuring and understanding Ubuntu involved too much time and effort. I want to use an operating system, not fiddle with one.
jbanana: Badly drawn banana (Default)
I cloned of a repo to a USB stick and took it away to make changes. Then I wanted to put the changes back:
$ cd <clonedgitrepo>

$ git push
<blah blah blah>
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to '<remotegitrepo>'
Oh dear. But after some googling, I found I can do this:
$ cd <remotegitrepo>

$ git checkout --detach
<blah blah> 'detached HEAD' state <blah blah>

$ cd <clonedgitrepo>

$ git push
<blah blah blah - works>

$ cd <remotegitrepo>

$ git checkout master
<blah blah blah>
Success! Now to post this to DW so that I can find it again next time that happens...

RAM disk

Mar. 12th, 2013 12:16 pm
jbanana: Badly drawn banana (Default)
Simple, free, quick: http://www.ltr-data.se/opencode.html/#ImDisk

I was parsing some logs. It took ages. Eventually I realised that I was fetching the gigabytes umpteen times from a remote machine. Oops. I have a stupid amount of RAM. If I fetch them once to a huge RAM disk, I can do parsing in seconds rather than hours.

Edit: Stupid amount of RAM on my work computer, that is - at home it's stupid for the opposite reason.

More bits

Mar. 7th, 2013 11:41 am
jbanana: Badly drawn banana (Default)
I got a shiny new 64 bit computer at work recently. So sometimes when I want to get download software, I have to choose the version with enough bits. Although I have 64 Intel bits, the right version might be AMD64, or any of x64, x86-64 and x86_64. I've never been offered IA-64, but I've read enough to know to avoid that because although that would be 64 bits, they're the wrong kind of bits.
jbanana: Badly drawn banana (Default)
Remember my UI generator, Compositor, that I mentioned before? Never mind. 8~)

I released a new version today: http://sourceforge.net/projects/compositor/files/0.3/
Page generated Jun. 22nd, 2017 02:18 pm
Powered by Dreamwidth Studios