Skip to content

Instantly share code, notes, and snippets.

@hendryfoe
hendryfoe / latency.txt
Created March 17, 2024 05:49 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@hendryfoe
hendryfoe / multiple_ssh_setting.md
Created December 2, 2023 03:48 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.
@hendryfoe
hendryfoe / clean_code.md
Created April 8, 2023 09:44 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@hendryfoe
hendryfoe / find.sh
Created February 12, 2023 06:23
"find" command in linux
# https://www.freecodecamp.org/news/how-to-search-files-in-the-linux-terminal/
find -name <file_name>
# find file by "case-insensitive"
find -iname <file_name>
# find file by "regex / pattern"
find /path/to/search -name "*.txt"
@hendryfoe
hendryfoe / format-currency.js
Created November 6, 2022 15:53
format currency utility
export function formatCurrency(
value: number,
locales: string | string[] = 'id',
options: Intl.NumberFormatOptions = { style: 'currency', currency: 'IDR', minimumFractionDigits: 0 }
) {
return new Intl.NumberFormat(locales, options).format(value);
}
export function formatCurrencyWithoutPrefix(value: number, locales: string | string[] = 'id') {
return formatCurrency(value, locales, {});
@hendryfoe
hendryfoe / chunk.js
Created November 6, 2022 15:52
chunk items
function chunk(items: string[], size: number) {
const chunks = [];
items = ([] as string[]).concat(...items);
while (items.length) {
chunks.push(items.splice(0, size));
}
return chunks;
}
@hendryfoe
hendryfoe / example-resume.json
Last active September 11, 2022 15:35
Example resume content
{
"contact": {
"firstName": "John",
"lastName": "Doe",
"phone": "+1 123 456 789",
"email": "johndoe@mail.com",
"linkedin": "https://www.linkedin.com/in/johndoe",
"summary": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat"
},
"experiences": [

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example