The regex [,-.]
A funny post I wanted to archive
A funny post I wanted to archive
I had a discussion with a colleague on how to persist a sorted (linked?) list in MySQL, and would like to write down my thoughts on this since this is likely a problem I will face in the future. There must be a better way of thinking about this than I’ve come up with. If you have an idea, don’t hesitate to send me an email. Problem description We have a sorted list of a generic length....
A simple docker command to start MySQL on a tmpfs. Things to note: Mounting localtime affects MySQL server timezone You need to have a my.cnf at the given location ($HOME/docker/mysql/my.cnf) You probably need to create /var/lib/mysql before running the command Setting sql_mode="" is probably not needed for most applications. sudo docker run -d \ --name mysql7 \ -v/usr/share/zoneinfo/Europe/Stockholm:/etc/localtime:ro \ -v$HOME/docker/mysql/my.cnf:/etc/my.cnf \ -e MYSQL_ROOT_PASSWORD=root \ -e MYSQL_ROOT_HOST='%' \ -p3306:3306 \ --mount type=tmpfs,destination=/var/lib/mysql \ mysql/mysql-server:5....
When you have an international database, how do you make sure that the collation is correct for all locales? Here are some thoughts. Note that you have to be careful when mixing collations in queries or SQL will complain. Table with virtual, generated columns CREATE TABLE `note` ( `id` bigint NOT NULL AUTO_INCREMENT, `text` varchar(256) DEFAULT NULL, `text_swedish` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_swedish_ci GENERATED ALWAYS AS (`text`) VIRTUAL, `text_danish` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_danish_ci GENERATED ALWAYS AS (`text`) VIRTUAL, ....
Curated list of interesting talks / lessons Psychology Jonathan Blow - Techniques for dealing with lack of motivation, malaise, depression Lists Conf42: Cloud Native 2021 Logging Making Logs Work for you with Fluentd Caching Architectural Caching Patterns (for Kubernetes) - Good caching primer Docker Images Securing Containers by Breaking In - Good image security primer
I have always neglected to write down java tools and commands that I use for troubleshooting. I will try to put in on this page. Memory and Threads There are many tools to measure java memory. In my experience, the easiest way to troubleshoot locally is to hook your development environment up to VisualVM. There are even plugins for it in e.g. IntelliJ. It is probably possible to do this to a production server as well, but that would likely impact performance....
Things I have learned from troubleshooting mySQL queries Links Index och prestanda i MySQL Join types (from explain) MySQL Profiling Commands # Run query without cache SELECT SQL_NO_CACHE * from users where name like 'Ol%'; # Profiling SET SESSION profiling = 1; SHOW PROFILES; SHOW PROFILE FOR QUERY 3; SHOW STATUS LIKE 'Last_Query_Cost'; How to index/optimize Optimize OR Example: SELECT * FROM users where customerNumber='qwe' OR birthDate='2020-01-01'; You need an index for each OR, which will create a merge index on modern innoDB....
# Remove DIRECTORY_NAME from all commits, then remove the refs to the old commits # (repeat these two commands for as many directories that you want to remove) git filter-branch --index-filter 'git rm -rf --cached --ignore-unmatch DIRECTORY_NAME/' --prune-empty --tag-name-filter cat -- --all git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d # Ensure all old refs are fully removed rm -Rf .git/logs .git/refs/original # Perform a garbage collection to remove commits with no refs git gc --prune=all --aggressive
One problem which I encounter time and time again when creating a webpage or applications is matching text color with a changing background color. When creating a GUI you usually create a lot of white boxes with a black text on it, just to get sizes and stuff matching. Then later a designer or customer decides on a theme which affects how that box looks. Most of the time the background and text colors are hand-selected so they match well enough, but from time to time you have to create a box which can change background color on demand, and then you have to have the text color matching to make the box readable....
Escaping strings in regex replace s.replaceFirst(Pattern.quote("text to replace"), Matcher.quoteReplacement("replacement text"));