MySQL case-sensitive LIKE search

When searching for partial strings in MySQL with LIKE you will match case-insensitive by default*. SELECT name FROM users WHERE name LIKE 't%' +--------------------+ | name | +--------------------+ | Test | | test | +--------------------+ If you want to match case-sensitive, you can cast the value as binary and then do a byte-by-byte comparision vs. a character-by-character comparision. The only thing you need to add to your query is BINARY. ...

February 25, 2019 · David Hamann

Hidden in plain sight: Alternate Data Streams

Have you ever wondered how a file in a file listing is shown with size 0 bytes but can still contain data? Or maybe wondered where all that meta data is stored, how malware can infect files or just how you can “hide” stuff in a file? Let’s talk about Alternate Data Streams to learn more. ADS - Alternate Data Streams When you hear “Alternate Data Streams” you may think about resource forks in Mac OS HFS. But we’re talking about Windows and NTFS. Back in the days of Windows NT 3.1 (ha!), NTFS streams were actually implemented to support the Mac resource forks. ...

February 23, 2019 · David Hamann

UnicodeError when running Python script via macOS LaunchAgent

If you are getting UnicodeErrors when reading/manipulating files using a Python script launched by a LaunchAgent or crontab, the problem might lie in the “current locale encoding”. Sample script Let’s assume you have the following code in a script set up to be launched by a LaunchAgent (also see my article on LaunchAgents): with open(some_path_to_file) as f: f.read() Let’s also assume that some_path_to_file points to a txt file containing some emojis (hey, why not? 😎) or some other unicode characters. ...

December 7, 2018 · David Hamann

Watch a log file and send new lines to an HTTP endpoint – with log2http

Recently, I wanted to watch a couple of log files for new entries and have them sent to an http endpoint for collection and later analysis. I did a quick research on what tools exist, but eventually decided to create a small Python app myself which doesn’t require a complicated setup. I thought of something along the lines of: pip install <the module> Define which log files to watch and where to send the contents to Run it from the terminal. And so I built it. ...

October 20, 2018 · David Hamann

Debugging stories: What's that 404 error?

Here is a little story about resolving an issue with a web site that turned out not to be an issue with a web site :-) A client approached me and asked, if I could look into an issue they were having with their web app. Multiple users, mainly from mobile devices, were reporting 404 Not Found errors when accessing the site’s domain. Server error for some devices? 🤨 It sounded like a strange thing that the server would give a 404 for some mobile devices. I tried to reproduce the issue, but was not able to do so, neither on one of my devices (mobile or not) nor on devices from an external device farm. ...

October 7, 2018 · David Hamann