Keeping it quick (Perl crypto)

It’s generally worth installing one of the math modules for Math::BigInt to use early on after installing perl if you want to ensure your installs (and your perl in general) goes as quickly as possible. Some of the crypto and random number modules use Math::BigInt and without a fast module under the hood they can take quite a long time to do anything.

If you use cpanm to install them use verbose mode (-v) because it’s quite likely they will either ask for input or fail the first time as they check for dependencies.

cpanm -v Math::BigInt::GMP
cpanm -v Math::BigInt::Pari

There may be good reasons to choose one module over the other but I don’t know what they are are. I just went with the one that installed easily. It makes quite a noticeable difference to installing certain modules like Crypt::DH. In fact you can see the time it takes without a fast library in the bug reports against it.


vim dependency

I have just been trying out eclipse and I realised I’ve become so used to vim I’m really a clutz with a regular text editor now. When it comes to programming I’ve become dependant on vim. My recent addiction started when I got a laptop with lame arrow keys and figured vim would make more sense. I installed vim and viemu for Visual Studio and never looked back. These days I’m just using vim since I’m working on linux but I’m really heavily dependant on it. It’s odd because as I type this in a regular editor this is fine, but when I see curly braces I feel lost without vim.

Luckily there is a plugin for eclipse called vrapper. It has most of the things I need. There are a couple of bits missing, but it’s enough to keep me from feeling all at sea.

I think I’ll take a look at the source code now it’s on github. I don’t know whether I can contribute to the project, but it’ll certainly be interesting to see a vim emulator as it’s still in the process of being built.

Oh and just in case I forget, the way to install new software is on the Help menu in eclipse.

Git merging binary files by hand

For some reason I have problems finding info on dealing with merge conflicts with git when it comes to binary files. Most of the time I know exactly how I want to deal with the conflict, but I always have trouble remembering how to actually accomplish that with git.

The simplest way assuming you don’t want to use mergetool because you don’t have a decent tool that can be trusted with binary is to use git show and then git add then git commit. A slightly clunkier (but simpler?) method is to do the git show then do a git mergetool but exit without saving, confirming the change worked though.

As usual the git help and general messages are the most useful reference. From the git help merge for the information about merging. Assuming I had a conflict with a file called t/test.db.

git show :1:t/test.db # show the common ancestor
git show :2:t/test.db # show the HEAD version (i.e yours)
git show :3:t/test.db # shows the MERGE_HEAD version (i.e. the one you just tried to merge in).

So assuming I wanted to take the one I just merged in I’d do this,

git show :3:t/test.db > t/test.db
git add t/test.db
git status # this perversely now says there is nothing to check in 
git commit # do it without a message and it’ll do a default merge one for you.

The alternative simpler but more perverse way to do it is to replace the git add onwards with git mergetool, and run through that flow, obviously not doing anything in the actual merge tool.

Of course doing this by hand isn’t exclusively for binary files, you can do the same things with your text file. Personally I don’t think I’ve found the need though, hence my trouble remembering how to deal with things this way when I do need to.