Guarding Against Code Bloat with static_assert
Powerful languages make it easy to overuse resources – especially memory. static_assert is a good way to detect these problems early. In a recent project, I created a hash table with 256 buckets where I needed to add a random…
BadgePlz is Malware (maybe)
We installed a widget that displays our instagram photos on our blog sidebar at blog.mimoco.com . Its a nice widget called “BadgePlz”. But sadly this widget is definitely malware. It will periodically redirect your users to porn sites. It appears…
Get USB Drive Serial Number on Os X in C++
Getting the serial number for a USB Serial drive on Os X is tricky just like it is to get a USB serial number on Windows. We want to get the serial number of a USB Flash disk that is…
Overloading Global operator new and delete
Programmers are often advised not to overload global operator new, and to stick to overloading just class specific operator new. The arguments against are many, but they basically boil down to that it is difficult to do it correctly. But…
Get USB Drive Serial Number on Windows in C++
Getting the serial number of a USB device in Windows is a lot harder than it should be. ( But it’s a lot easier than getting the USB serial number on Os X!) It is relatively simple to get USB…
Pseudo Functors and Template Magic
A functor is an object that works like a function. That is it overloads operator(). They are useful when you need to create a series of functions each of which works mostly the same way, but you want that instance…
Implementing Portable Threads and Mutexes
Implementing a portable framework for multi-threading doesn’t have to be difficult or error prone. With the right framework, implementing multi-threaded programs can be pretty simple, and you can hide all the platform dependent functions. You can also implement your threading…
Generating 64-bit Random Numbers in a Given Range
There are good standard ways of generating 32-bit random numbers. If you need something really simple, it is possible for example to generate decent random numbers with a Linear Congruential Random Number Generator:
Using BerkeleyDB to Store Serialized Objects in C++
I’ve been working on a C++ interface to Berkeley DB to support some ongoing projects. The goal is to create an interface that allows me to store serialized C++ objects in a database. Each object is flattened into a text…
Link Errors Compiling MySQL C++ Programs on 64-bit Windows
I’m starting to code up a simple MySql connector class. Here is the code for the class. First the header: