When using XML-RPC over SSL with Ruby, you may receive the following annoying warning:
warning: peer certificate won't be verified in this SSL session
There is a very simple (but very poorly documented) fix for this. After instantiating your XMLRPC::Client object…
server = XMLRPC::Client.new3( ... )
Add the following line:
server.instance_variable_get(:@http).instance_variable_get(:@ssl_context).instance_variable_set(:@verify_mode, OpenSSL::SSL::VERIFY_NONE)
Now do your XML-RPC calls as usual:
result = server.call( ... )
I think I might be! After reading an article claiming that only 10% of programmers can write a binary search I decided to give it a shot. After about 20 minutes, I came up with this:
def bsearch(array, search, start_ix=0, end_ix=array.length)
mid_ix = start_ix + ((end_ix-start_ix)/2).ceil
if array[mid_ix] == search then
puts "%d found at position %d" % [ search, mid_ix]
elsif start_ix == mid_ix then
puts "%d not found" % [ search ]
elsif array[mid_ix] < search
bsearch(array, search, mid_ix, end_ix)
elsif array[mid_ix] > search then
bsearch(array, search, start_ix, mid_ix)
end
end
bsearch([10, 20, 30, 40, 50, 60, 70, 80, 90], ARGV[0].to_i)
It’s probably not by best work, and I’m pretty doubtful that I could have done it in the same amount of time under the stress of a job interview. But it works, and that’s good enough for me, considering that I haven’t been a full time programmer in quite some time and haven’t written anything like this since college. ;-)
Way back in 2006, I spent a week or so trying to use ORM in a project I was working on, only to discover that rather than making my life easier, it constantly prevented me from doing what I wanted to do. I spent an inordinate amount of time trying to convert SQL queries into ORM, but I kept ending up with slower, more complicated messes. And since this particular project required me to pull information out of very large databases very quickly, I was never completely comfortable trusting an abstraction layer to optimize SQL queries as well as I could.
It’s been a few years since I’ve developed software full-time, but since I still encounter articles about how great ORM is, I figured that either the situation has improved since then, or maybe I was just too stupid to harness the power of ORM. But then I found someone who has come to the same conclusions I did way back in 2006, and has written about them a lot more eloquently than I did in my original rant. At least I’m not alone anymore!
The xen-vm-autosnapshot.py script has been updated with an important new option: –snapshot-tag. I still can’t believe I made such a silly oversight, but previous versions of this script had no way of differentiating between snapshots created automatically and those that were created manually. So if you happened to have some old manual snapshots lying around, the snapshot-rotate routine would have rotated them along with all the rest.
The –snapshot-tag option fixes this by allowing you to “tag” each snapshot as it’s created. Then the snapshot-rotate routine will only consider snapshots with the correct “tag.” This also allows for more advanced snapshot/rotation schedules.
Thanks to Adam Adamou at NJEDge.Net for his input.
I’ve just updated NagiosPluginsNT for the first time in a long time. I don’t really get to spend much time on this project anymore, since my current employer has moved away from Nagios.