Anti-nuisance lawsuit warning: The purpose of these notes is to remind me, Zoegond, of stuff or to help me work stuff out. They may contain mistakes.

Quick

  • ($a, $b....) = unpack("A2A7...", $packed)
  • push( array, list )

Friday, June 19, 2015

local and do

'local modifies the listed variables to be local to the enclosing block, file, or eval' - but
  • a do is only 'largely' like an eval - this is one of the respects in which it differs
  • the script that you do may be physically in another file, but when you do it, it is as if it is part of the file where the do is
Or to put it more succinctly, if a.pl uses a filehandle FH, and so does b.pl, and you do b.pl from a.pl, you cannot use local(*FH) in b.pl to stop b.pl's FH from being the same handle as a.pl's.

I worked round this by putting a package X at the top of b.pl, no doubt there are other ways.

Tuesday, June 16, 2015

Always catch exceptions!

I never usually bother to try and catch exceptions when writing experimental code because I expect the runtime to throw up a default exception dialogue.

But after much fruitless fiddling with a toy application using SqlDataAdapter, I found that instead of one of those dialogues, you can just have an infinite hang instead.

I was doing SqlAdapter.Fill(dataset) without first setting dataset to new DataSet(), which (when I eventually put a try-catch round it) I discovered was causing a System.ArgumentNullException - 'Value cannot be null'.

A lesson I shan't forget, because it's wasted about 4 hours today.

Saturday, June 13, 2015

C# project references

The 'dynamic' in DLL as far as C# is concerned, when you've included a DLL reference in your solution, only extends up to the point at which you compile the solution.

So if you have a class library, and a unit test to which you've added a reference to the library, it's no good fiddling with the library in the IDE while running your unit test from a prompt. The unit test will, it seems, have linked into itself the class library DLL as it was when you compiled the unit test: more of a statically linked library in this case.

Accessing Windows share from Linux machine

Just do the first half of this procedure:
www.howtogeek.com/176471/how-to-share-files-between-windows-and-linux
(stop when you get to 'Creating the Share on Linux' - the article describes how to connect in both directions). Apologies for not putting in a link, but for some reason Blogger kept prefixing the address of this blog to the URL.

The only bit I had to change was that my Linux machine couldn't resolve the name of my Windows 7 machine. So

sudo mount.cifs //WOPR/D /mnt/woprd -o user=falken
didn't work, but
sudo mount.cifs //192.168.2.3/D /mnt/woprd -o user=falken
did. In case you don't know, you can find the IP address of the Windows machine with 'ping WOPR' (or whatever its name is) from a command prompt on that machine.

What annoys me most is that I spent all morning wading through articles and forum responses on this subject, and not one of them mentioned that you only need to set up Samba on the Linux machine if you want to access a shared folder on that machine from a Windows machine - the exact opposite of what we require here.

But I did learn something very useful - if you substitute 'linux' for 'ubuntu' in searches, you'll get much more helpful answers, and you won't have to visit askubuntu either. It's vying with the Mozilla forums in uselessness.

Further sayance... what you seem to be doing when you do this is setting up a connection using the CIFS protocol, which I think Windows refers to as SMB protocol, or perhaps it's that Microsoft's implementation of SMB is enhanced to include CIFS functionality. I don't know and I don't need to, because the point is that CIFS and SMB are the keywords to use when doing searches about this stuff.

Which is what I did when I was trying to work out how to see what username I was showing up as from Windows' point of view - do net session to see all SMB connections.

And if you're wondering why you can't paste onto your Windows share from Linux in the original scenario above, even though you've mounted rw, it's probably because you've only given root (at the Linux end) rw permission. You just need to sudo the application in which you're trying to do the pasting (thunar in my case).

Thursday, June 4, 2015

C# class library

If you create a class library which uses (eg) System.Data, you have to explicitly add a reference to System.Data.

I'm guessing that you have to do that in this context, but not (eg) when making a Windows Forms application, because in the latter case the references are included in the project for you when it's generated.

Followers

Blog Archive