Optimizing MySQL Queries et. Indexes

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. If you are missing an index for one OR you will have to do a full table scan. Basically, one condition can ruin the query. If you create a joined index on (customerNumber, birthDate) or (birthDate, customerNumber) they will have not effect. To use a joined index you have to do two solo queries and UNION them. ...

May 24, 2020  | 

Remove subfolder from all git history

# 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

February 27, 2020  |  🏷️Git

Using black or white text depending on background color

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. I have done too many slightly different solutions to this problem, so I thought I would write something down here. Since most of the time, text colors are off-white and off-black, the formula should be tweakable to match any given hue. ...

May 11, 2019  | 

Java Regex Cheatsheet

Escaping strings in regex replace s.replaceFirst(Pattern.quote("text to replace"), Matcher.quoteReplacement("replacement text"));

March 14, 2019  |  🏷️Regex

Merging git repositories to a monorepository

BFG-clean repository If you’ve had the bad habit of checking in binary data, this is your chance to clean it up. If so, then run these lines. Tweak the bfg command to your taste. cd git-repo # Optional. Will likely make you able to remove more files. You might want to remove remotes as well. git tag -d $(git tag -l) cd .. java -jar bfg-1.13.0.jar --strip-blobs-bigger-than 5M --delete-files "*.{class, jar, png, svg, ico, zip}" git-repo cd git-repo git reflog expire --expire=now --all && git gc --prune=now --aggressive Move the repository to a subfolder Replace subfolder below with the real subfolder name ...

November 8, 2018  |  🏷️Git 🏷️Bfg

Spring Microservices/Notes

Links Microservices: Health monitoring

May 7, 2018  | 

CSS Cheatsheet

Links 30 Seconds of CSS A Complete Guide to Flexbox

April 18, 2018  |  🏷️Css

Django2 (python3) framework documentation collection

Some collected documentation for building a generic page in Django2 (python3) Python language Python3 libraries Framework Django documentation Django documentation - topics Deployment Django and nginx Django and uWSGI Security in Django Performance and Optimization in Django Deployment checklist Example pairing Django/nginx

February 4, 2018  | 

Rocket (rust) backend documentation collection

Some collected documentation for building an API backend in Rocket (rust) Rust language Rust by Example Framework Rocket Documentation Docker Github Page Libraries Chrono - Time and Date Diesel - ORM

Luminous (clojure) backend documentation collection

Some collected documentation for developing in luminous. Clojure docs. Language. Luminous web. Framework. Sweet/Compojure API. Luminous building block for API. Compojure. Building block for Sweet. Swagger. Building block for Sweet. Ring. Building block for Compojure. Schema. Data types and validation. Libraries Buddy-hashers. For hashing, mostly passwords. Guides Restful Clojure