Dick Cheney is apparently not always a close-minded and incompetent liar.
In 1994 he was much more in tune with the truth: “It’s a quagmire”
Dick Cheney is apparently not always a close-minded and incompetent liar.
In 1994 he was much more in tune with the truth: “It’s a quagmire”
![]()
I had a need to obtain a block of ids from a sequence in Postgres. Sequences are used primarily for issuing unique id’s for primary keys. Normally they are issued one at a time. But periodically one needs to obtain a large block of ids. It’s possible to accomplish that just by looping over the sequence issuing function “nextval” sequentially until the correct number of keys has been issued - there’s no guarantee that you’ll get a block - you may get a non-sequential set depending on other table activity. So I talked with the postgres sql list about this and they helped me come up with the following solution, which appears pretty reliable and has relatively low downside.
I wish someone had shown me how to use Module methods correctly for creating “multiple inheritance” like features in Ruby. The “Pickaxe” book does a pretty good job (pub. Pragmatic Programmers) but all the info was scattered around a little. I thought I’d share a short piece of code which demonstrates easily how to introduce module methods into classes. You can install them either as class methods or instance methods. When referencing variables in these modules (such as “self”) after you install them into a Class, those references will refer to variables inside the Class, which is very handy. Ruby uses quite a bit of this internally, to implement iterators and other functions across multiple classes - in fact you can implement Classes and mix-in iteration if you support a few underlying functions that the iterator module needs to function.
Sometimes external libraries send warning or console output without asking in Ruby. Very rude! It turns out there is a nice library out there that helps with this problem - and the good news is that this library is already built right into Rails so if you’re developing with this framework you have this tool at your fingertips.