ruang.work

The Snippets page is a curated of useful code snippets gathered from various sources.

Add SSH private key to Keychain to be automatically available when ssh
Terminal window
ssh-add --apple-use-keychain ~/.ssh/id_ed25519
Github log format
Terminal window
git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset"
Gitignore File Isn't Working For Some Reason
Terminal window
git rm -rf --cached .
git add .
Javascript Filter Array
code {
counter-reset: step;
counter-increment: step 0;
}
code .line::before {
/* Style individual code line */
content: counter(step);
counter-increment: step;
margin-right: 1.5rem; /* Margin between line number and actual code element */
}
Javascript Reduce Array
code {
counter-reset: step;
counter-increment: step 0;
}
code .line::before {
/* Style individual code line */
content: counter(step);
counter-increment: step;
margin-right: 1.5rem; /* Margin between line number and actual code element */
}
React Conditional Rendering
const ProgressStep = (step: Step) => ({
current: <CurrentComponent step={step} />,
complete: <CompleteComponent step={step} />,
upcoming: <UpcomingComponent step={step} />,
})
const ProgressNav = ({ steps }) => {
return (
<nav aria-label="Progress">
<ol role="list">
{steps.map((step, index) => (
<li key={index}>{ProgressStep(step)[step.status]}</li>
))}
</ol>
</nav>
)
}