ReactJS: Synthetic Mouse Event Properties Null

While working with ReactJS, I added a click handler. I used console.log to dump the event object passed into the handler, but all the properties on the SyntheticMouseEvent were null.

synthetic-event

An insightful tip via StackOverflow point me in the right direction. Chrome and React interact strangely with the event object in this situation: Chrome does not copy the properties, and by the time Chrome prints the object to the console, React has nulled out the values. But at runtime, the properties are not actually null, they’re there.

Just reference your synthetic event properties directly instead of trying to dump the entire object.

Enable Custom Configuration Files in Lumen

Lumen does support custom configuration files, but they need to be enabled first.

You need to add calls to $app->configure('file.php') in your bootstrap/app.php. A cleaner method might be to make a config.php to contain the configure calls and then include that file from bootstrap/app.php.

If you want to use .env values directly, you can also uncomment Dotenv::load(__DIR__.'/../'); at the top of bootstrap/app.php. That will allow getenv('name') to work.

Rename extensions with the terminal

I had a directory full of files with the same extension, and a script was design to process any file in the given directory with that specific extension – to ignore the processing on a file, all I had to do was rename the extensions of all the files except the one I wanted to process specifically.

There’s a great answer on Ask Ubuntu, of all places.

rename ‘s/.original$/.new/’ *.new

SML: operator and operand don’t agree

I am tired of having to look this up every time I forget everything I know about SML.

Error: operator and operand don’t agree [tycon mismatch]
operator domain: ‘Z * ‘Y
operand: ‘Z

When you get this error, you have called a function with the wrong argument types.

The operator domain is what the function called expects, and the operand is what the function was called with.

To fix the problem, call the function with the proper arguments.

You can learn more about a variety of SML errors at the SML NJ error document.

Rust: core::ops::Fn(char) -> bool

Here’s a Rust error:

error: the trait `core::ops::Fn(char) -> bool` is not implemented for the type `&str`

I was trying to split a string of numbers with spaces a delimiter. Here’s the line for which this error occured:

let split: Vec<&str> = input_string.as_slice().split(" ").collect();

Apparently, split was expecting a single character, not a substring. This obtuse error was easily solved by changing the double-quotes to single-quotes.

let split: Vec<&str> = input_string.as_slice().split(' ').collect();