Worm with Glasses

Coding • DevOps • Personal

Oct 27, 2017

Oct 26, 2017

🔗 Delete Your Code

Ruairidh Wynne-McHardy writes:

We are all attached to the things that we create. From our relationships, to our work, to trivial things like the way we decorate our home — we don’t like to destroy things that we have put effort into.

That’s why it’s even more important to delete your code.

Never be afraid to throw away code that’s not working when the requirements change. You know more about the reguirements now than you did when you first wrote the code. Be brave.

Delete Your Code

Oct 26, 2017

🔗 12 Most Common Writing Mistakes You Want to Avoid at All Costs

Entrepreneur has a list of their tweleve most common writing mistakes. These mistakes are targetted to business style writing:

  1. You use industry buzzwords that are hackneyed and phony.
  2. You assume the reader knows the acronyms or identity of the people you mention.
  3. You overuse CAPS and punctuation.
  4. You compose overly complicated, overly abstract or flowery writing.
  5. You mix single objects with plural pronouns or single subjects with plural verbs.
  6. You make one of these common mix-ups. (i.e., between/among, less/fewer, then/than, etc.)
  7. You make vague claims.
  8. You slip into slang.
  9. You use unprofessional-looking font.
  10. You make frequent and immature spelling mistakes.
  11. You use quotes incorrectly.
  12. You start a sentence with a numeral.
12 Most Common Writing Mistakes You Want to Avoid at All Costs

Oct 26, 2017

Oct 18, 2017

🔗 Efficient pagination of a table with 100M records

This Chapter is focused on efficient scanning a large table using pagination with offset on the primary key. This is also known as keyset pagination.

Efficient pagination of a table with 100M records

The key insight is to use the primary key as the offset to avoid missing records (if they’re deleted between invocations) and to increase performance by using a RANGE join type, which is much faster (constant time.)

Simplified algorithm:

  1. We get PAGE_SIZE number of records from the table. Starting offset value is 0.
  2. Use the max returned value for the primary key (i.e., user_id) in the batch as the offset for the next page.
  3. Get the next batch from the records which have the primary key (i.e., user_id) value higher than current offset.

For example:

SELECT user_id, external_id, name, metadata, date_created
FROM users
WHERE user_id > 51 234 123 --- value of user_id for 50 000 000th record
ORDER BY user_id ASC
LIMIT 10 000;