Oh gosh. Can of worms. You sort of have to use const everywhere you safely can, because somebody else's code might force you into it.
Yeesh. I'm going to write a "deconstifier" shim that allows you to interface
with other people's code, casting between const and non-const without throwing
a compiler warning. And I'm going to reserve the domain "deconstifier.io"
because when you have an .io domain people automatically assume that you are
an inarguably brilliant developer.
""CONSIDERED HARMFUL" CONSIDERED HARMFUL" CONSIDERED HARMFUL
""CONSIDERED HARMFUL" CONSIDERED HARMFUL" CONSIDERED HARMFUL
Er... in C++, you can use 'const_cast<>()'.
But, I find const helpful. It hasn't been a problem for me.
mysql, you surprise me.
In 2012, someone complained that their documentation doesn't state that concatenating a string past the max_allowed_packet will result in a 'null' for the string, and how heinous that is, etc.
So they documented this fact. But not in the part of the documentation where you'd look at the concat or concat_ws string manipulation functions. No, that would be a wholly logical, reasonable, intuitive place to look for such a thing. Instead, they documented it at the end of the table of string functions, where everyone would look for such a thing.
The *only* reason I found this was after looking at the bug report. I don't normally make a habit of looking tediously over every shred of documentation when I need to research a problem, because, I dunno, I have other things I need to accomplish in a day or something.
I dunno... I guess I could complain and be the first person since 2012 to point out the ridiculous nature of their solution and be known as 'That Guy' or something. On the other hand, I could just tuck it away as My Little Secret and whip it out someday when the right set of circumstances come about where such information is useful.
In the meantime, fucking hell.
You can't have a BLOB past max_allowed_packet either.
lame, but I guess not enough people are yelling.
Well, in mysql, a BLOB maxes at 65,535, while most people have max_allowed_packet set to something considerably larger. Well, in our case, it is set to the same size as a MEDIUMBLOB or MEDIUMTEXT.
However, *nothing* can be set larger than max_allowed_packet, I think, so if you wanted to really confuse someone, set that value to 10 and watch the suck happen.
I was referring to BLOBs as a class. LONGBLOB goes to 2^32, and would just be referred to as BLOB on Oracle, where BLOB storage is not in the main table record.
<GRIN> LS - I was kidding. We use BLOBs and LONGBLOBs.. But we also started
describing things as BATFs cause it was funny.
Heh, BATFs...
If you had the 4gb LONGBLOB, you'd need to change your max_allowed_packet in mysql to something that could accomodate that size. I wonder how many people even know there's this variable limiting how much they can actually put in the table?
I was referring to BLOBs as a class. LONGBLOB goes to 2^32, and would
just be referred to as BLOB on Oracle, where BLOB storage is not in the
main table record.
What the f**k are you people storing in your databases?!?
Actually, in our case, that's almost literally what we do for one situation.
We have metadata associated with the file, and we perform searches within the file's contents for information. To keep our interfaces for this kind of stuff uniform, we keep the file itself in a column of the database.
As the whole database is semi-temporary by the nature of what we're doing, it isn't a big deal. If we were doing something that lasted longer, yeah, this isn't the approach we'd want to use.
Hey web developers.
We all know by now that "synchronous xmlhttprequest is deprecated" in jQuery.
But what about doing the same thing *without* jQuery? Is support for doing a synchronous xmlhttprequest, directly from javascript, something that will continue to be supported by the browsers?
(Yes I know it's a bad idea. But ever since I switched my main desktop to Windows in January 2015 I no longer care about anything.)
We all know by now that "synchronous xmlhttprequest is deprecated" in jQuery.
But what about doing the same thing *without* jQuery? Is support for doing a synchronous xmlhttprequest, directly from javascript, something that will continue to be supported by the browsers?
(Yes I know it's a bad idea. But ever since I switched my main desktop to Windows in January 2015 I no longer care about anything.)
Anyone fluent in Rust by any chance? Having a problem describing what I want
to the compiler in terms of type annotations.
Specifically, I'd like to make a globally accessible hashmap, like so:
// will not compile
static mut user_list : HashMap<String, Rc<RefCell<UserRecord>>>;
Problem is, there is no way to statically initialize a HashMap, so I cannot use an initializer, which means I cannot declare this as static. I tried wrapping this in an Option<T> type and initializing it to None, but that fails as well, since in order for this to make sense, I have to use Rc<RefCell<UserRecord<'static>>>, which is not correct either, since the user records will not out-live the user_list variable (just the opposite in fact).
The only way I can see around this is to declare and initialize this variable in main() and just pass it to everything as an argument, but holy hell, that's a nightmare. There has to be a better way.
Thanks.
Specifically, I'd like to make a globally accessible hashmap, like so:
// will not compile
static mut user_list : HashMap<String, Rc<RefCell<UserRecord>>>;
Problem is, there is no way to statically initialize a HashMap, so I cannot use an initializer, which means I cannot declare this as static. I tried wrapping this in an Option<T> type and initializing it to None, but that fails as well, since in order for this to make sense, I have to use Rc<RefCell<UserRecord<'static>>>, which is not correct either, since the user records will not out-live the user_list variable (just the opposite in fact).
The only way I can see around this is to declare and initialize this variable in main() and just pass it to everything as an argument, but holy hell, that's a nightmare. There has to be a better way.
Thanks.
Answering my own question: you don't. You have to wrap the global variable
into a single function as a static variable. Initialize it statically to
None, then use a match-clause to lazily create the value on first access.
Easy enough to do manually (if a bit boiler-plate-y), but there's a crate that automates this (via macros) called "lazy-static".
Easy enough to do manually (if a bit boiler-plate-y), but there's a crate that automates this (via macros) called "lazy-static".
Riddle me this, Batman.
What is the point of UTF-16?
It's variable length, like UTF-8 is, but takes up no less than two bytes per character, even though the majority of text still falls in the 0x00-0x7F range (particularly in Western languages). So why would anyone want to choose an encoding that is "variable length but no less than two bytes" when there is a "variable length, as low as one byte" encoding available?
UTF-16 seems to neatly combine the worst of both worlds. So why does it exist?