2012 ...
januari (3) februari (5) maart april (6) mei (2) juni (1) juli (2) augustus september (5) oktober (1) november (2) december
2012-02-02 14:02 i3006 [permalink]
Very nice, I'm trying it.
Is there a way to use >=. <= operators for quering objects? I know I should use >, but, how to use it with TMongoWireQuery?
2012-02-02 21:21 r1693 [permalink]
If I look at this page, the query you're looking for would look like this in JSON notation for example 'x>10':
{x:{$gt:10}}
in Delphi notation this could be written as:
BSON(['x',BSON(['$gt',10])])
or in the condensed form (where one BSON call does the embedded levels):
BSON([x,'[','$gt',10,']'])
COM/ActiveX objects and Windows Vista and newer
2012-02-02 21:55 i3008 [permalink]
Applications that provide one or more ActiveX/COM automation objects, created with older versions of Delphi, running without administrative privileges, throw an EOleSysError when strarting up (typically from within the Application.Initialize;
). This is because the application will try to register its type library and class registrations when it starts. Add this unit to the project to silent this error at run-time:
unit comFixW6; interface implementation uses Windows, SysUtils, ComObj; var SaveInitProc:pointer=nil; procedure FixComInitProc; begin try if SaveInitProc<>nil then TProcedure(SaveInitProc); except on e:EOleSysError do if e.ErrorCode<>TYPE_E_REGISTRYACCESS then raise; end; end; initialization SaveInitProc:=InitProc; InitProc:=@FixComInitProc; end.
2012-02-16 20:26 md5 [permalink]
This is odd, it looks like there isn't an open source md5.pas unit. And by open source I mean under a permissive license or without copyright or licensing. So I set out to write my own and share it here. I based it on the original RFC, and even more the description than the reference implementation, because it uses a few of those C tricks I don't like. I hope it's performant enough, in case you're demanding performance of it. I've done some testing myself, but if you detect any kind of issue, please let me know.
md5.pas
with MD5Hash
for strings, sometimes used with passwords
md5Stream.pas
with MD5HashFromStream
which takes any kind of stream (TFileStream, TMemoryStream...), and optionally a preset number of bytes to take from the stream (from the current position!).
Enjoy.
Update: since MD5 and SHA1 are really similar, I've done the same for SHA1 and added sha1.pas and sha1Stream.pas.
Update 2: since I needed it for something else, I've added RIPEMD160 as well. And while I'm at it SHA256 as well
Update 3: added MurMurHash3...
Important: though the headers state "License: no license, free for any use" it also implies no warranties are made. No warranty of a fitness for a purpose or merchantability, and non-infringement and all. No liability for claims or damages with all your contracts and torts and otherwise arising connection dealings you know who you are. I expect I'm sufficiently covered by the laws of my home country (not the U.S.).
Also: in the spirit of this warning (Act 3 second image) I make no guarantees whatsoever about robustness against side-channel attacks or anything else for that matter.
Update 4: I've also included the files in a github repo here.
2012-02-16 20:28 r1699 [permalink]
→ md5.pas
Code in a slightly modified form also used here: https://github.com/stijnsanders/TMongoWire/blob/master/mongoAuth.pas