Skip to main content

Posts

Showing posts from May, 2022

Java ForkJoin Pool CheatSheet

Java ForkJoin Pool # Java ForkJoin Pool 1. As it sounds, assist distribute work 2. From java 7 3. Based on Doug Lea's work 4. As it sounds, break to simpler tasks    1.  Ideally, no worker thread idle        1.  Threads steal work 5. Classes you use    1.  ForkJoinPool        1.   Implements ExecutorService        2.   `ForkJoinPool = new ForkJoinPool(int parallelism)`             1.   With no arg by default, numProcessors        3.   Pool adjusts its size! (though you specified number)   1.   Send ForkJoinPool Tasks with        1.    Execute() - asynchronous        2.    invoke() - sync awaits        3.    submit() - Async get Future    2.  ForkJoinTask        1.  isDone() - true when complete        2.  isCompletedNormally() - finished without exception        3.  isCompletedAbnormally() - true cancelled / exception 6.  How to use     1. Create `RecursiveTask`     2. Implement `compute()` in RecursiveTask to do your work        1. You can create additional tasks inside it, that&#

DynamoDb Read Capacity Units - RCU

1. DynamoDb Max Item Size is 400KB 2. 1 RCU is ~1 Read request from the DB 3. Why is it only roughly 1 read request because we could have multiple types of read requests 4. We could have a consistent read request 5. We could have an eventual consistent read request 6. We could have a transactional read request 4. If the item we read is up to 4kb and we read with eventual consistent than we could actual make 2 such items read with 1 RCU 5. If the item i up to 8KB and we make an eventual consistent read than we could have a single read request per second with 1 RCU 6. If the item is larger than 4KB and we want to perform a consistent read request than this would require 2 read request at least. 7. If we need a transactional read request for an item up to 8KB then we would need even 4 RCU 8. If we need a transactional read request for an item up to 4KB then we would need 2 RCU that is because transactional read requires 2 phase commit the first RCU would be for prepare and the secon

4 Core Patterns for SEO

Relevance Your content is relevant to keywords On-page optimization In the past, could just repeat keywords Today, content keywords should be related Think TOPIC Not keywords Divide web pages by topics not by keywords Many pages same topic—google will get confused Aggregate keywords to topics Identify primary keyword within topic Topic in Url's Not good too deep – isn't that important  http://programminghacks.com/java/tips/interview/best-java-interview-tips.htmls http://programminghacks.com/java/java-interview-tips.html Title tag title  tag Header tags <h1>⁣ – Best  description of the web page <h2>⁣ – Synonyms  to topic <h3+>⁣ – You  don't have to optimize Keyword density copy from results 1 – 5 How many times your keyword appear vs your total words in your page Use tool tools.seobook.com/general/keyword-density LSI Latent Semantic indexing Prove you are on that topic if you discuss java interview tips, I guesstimate problem coding works would be in your p

LeetCode 3| Longest Substring Without Repeating Characters | Medium

Problem Given a string  s , find the length of the  longest substring  without repeating characters. ie. weqwjfd --> 4  (because wjfd is 4 chars) Problem Analysis String/Array Find elastic string within substring Though they asked to find the substring in examples they gave, they had the length  of the largest substring So, we need to return the length Thinking about solution We have a string we are going to need to scan it Largest --> elastic find the boundaries of the string Elastic + Array/String --> Sliding-Window  == TwoPointers But Sliding-Window class Solution {     public int lengthOfLongestSubstring ( String s ) {         int l = 0 ;         int result = 0 ;         Set < Character > set = new HashSet <>();         // We start with right pointer from 0, both left and right are at 0!.         for ( int r = 0 ; r < s . length (); r++) {             // As long as we have duplicates move left first. Trick! at first 0,0 no duplicates!          

Stagflation

 What is stagflation? Stagflation is an economic state where we have both below economical states happening simultaneously, inflation and no growth.  We can have periods of inflation, we can have periods of no growth, but when we have them together, we call this stagflation. So, stagflation is when we have both: We have inflation We don't have growth Let's define inflation , we have two mainstream definitions: Price inflation – the prices are getting higher We have a measure of a few goods in a basket – warning which goods The weight of these goods in this index changes over time to reflect their real life ratio Monetary inflation – increase in money supply Usually increase in money supply should reflect the actual economic growth We actually see big inflation in a combination of both price inflation and also monetary inflation.  During inflation periods, we have brief stagflation periods. Presently, we have over 4 decades of disinflation, but since 2020+ we started having co

Aws DynamoDb Part 2

Partitions and Performance For a single partition: - For a single partition key - You can have a hard limit around 3000RCU (Read Capcity Units) - You can have hard limit around 1000WCR - Partition key should evenly distributed among partitions - Accessing frequently a partition is called "hot partition" can cause performance issues. - General number of requests you make to dynamodb too high Partitions Best Practice - Use high cardinality attributions - itemId, cardId, SessionId - Use composite attributed - ComputerId+DisplayId - Cache - can use DAX (dynamodb accelerator for reads) - Add Random Numbers to make partition key high cardinality Consistency Models - DynamoDb supports both eventual and strongly consistent. - By default eventual consistency. - Eventual - Read response can be non latest, other write, stale, repeat get different answer, but keep repeating and will get latest answer. - Strongly - Always up to date data, can get error 500, higher latency, not supported

SEO And Domain Names

 Long gone are the days where you actually wanted to optimize your domain name for SEO.  Just think of it, if we could optimize our domain name and gain big time in SEO wouldn't everyone do this? This is just what happened in the past, today it's more important to have consistent data, to have your website existing over the internet for a long period of history, to have a reliable website without errors. Below is a brief diagram of a summary of chapter 12 of the great book 3 months to SEO.   1. Book 3 Months to No.1: The "No-Nonsense" SEO Playbook for Getting Your Website Found on Google -  https://amzn.to/3LE1v2F