Joined January 2013
·
Posted to
Using bitmasks to store settings
over 1 year
ago
@sheerun Why?
Posted to
Using bitmasks to store settings
over 1 year
ago
@encodes Indeed.
I actually learned this technique while coding for the ATLAS experiment at CERN which contains thousands of electronic chips where both physical and logical space are limited resources.
Posted to
The best todo list app for any developer
over 1 year
ago
* sudo rm -rf /*
- don't forget to run
Posted to
Using bitmasks to store settings
over 1 year
ago
Indeed, using bitmasks requires some serious testing.
And you sure can't use it for everything. In my case, I use it for a stupid collection of checkboxes.
Posted to
Using bitmasks to store settings
over 1 year
ago
That's a fair point.
If I'm not mistaken, all flavours of SQL support bitwise operations don't they? Hence one could query with SELECT * FROM users WHERE settings & (1 << 3) > 0
.
Isn't that right?
Posted to
Custom Rails error pages
over 1 year
ago
@jeroenr Thank you for that tip, I was looking for that exactly ;)
Achievements
375 Karma
143,385 Total ProTip Views
Walrus
The walrus is no stranger to variety. Use at least 4 different languages throughout all your repos
Charity
Fork and commit to someone's open source project in need
Python
Would you expect anything less? Have at least one original repo where Python is the dominant language
Mongoose 3
Have at least three original repos where Ruby is the dominant language
Mongoose
Have at least one original repo where Ruby is the dominant language
@sheerun I have a table dedicated to users settings with dozens of booleans columns and as many rows as users. That freaks me out. I much rather like a single integer field on the users table.
I never need to query on them, I only need to check a given record's settings.
Now to be clear, I never said people should use this technique blindly. Everyone should be sensible to how it fits there requirements. Just like everything else.
Also, I used ruby here to illustrate the point but the post was mostly intended to showcase the technique rather than the language used to apply it.