Skip to content

Instantly share code, notes, and snippets.

@hassam7
hassam7 / iterm2.md
Created July 5, 2025 12:11 — forked from squarism/iterm2.md
An iTerm2 Cheatsheet

Tabs and Windows

Function Shortcut
New Tab + T
Close Tab or Window + W (same as many mac apps)
Go to Tab + Number Key (ie: ⌘2 is 2nd tab)
Go to Split Pane by Direction + Option + Arrow Key
Cycle iTerm Windows + backtick (true of all mac apps and works with desktops/mission control)
@hassam7
hassam7 / iterm2.md
Created July 5, 2025 12:11 — forked from squarism/iterm2.md
An iTerm2 Cheatsheet

Tabs and Windows

Function Shortcut
New Tab + T
Close Tab or Window + W (same as many mac apps)
Go to Tab + Number Key (ie: ⌘2 is 2nd tab)
Go to Split Pane by Direction + Option + Arrow Key
Cycle iTerm Windows + backtick (true of all mac apps and works with desktops/mission control)
@hassam7
hassam7 / README.md
Created November 13, 2024 20:00 — forked from abelcallejo/README.md
Creating bootable Linux USB using Mac

Creating bootable Linux USB using Mac

mac

CentOS, Ubuntu, Slackware, etc. Whatever Linux-based OS it is, you can create a bootable USB for it by using a Mac.

1. Prepare the .iso file

Download it, copy it, whatever it takes to prepare that Linux-based OS .iso file

2. Convert the .iso file into a .img.dmg

@hassam7
hassam7 / zustand-internals.jsx
Created November 2, 2024 12:36
How zustand works internally
import { useSyncExternalStore } from "react";
// For more on the useSyncExternalStore hook, see https://react.dev/reference/react/useSyncExternalStore
// The code is almost identical to the source code of zustand, without types and some features stripped out.
// Check the links to see the references in the source code.
// The links are referencing the v5 of the library. If you plan on reading the source code yourself v5 is the best way to start.
// The current v4 version contains lot of deprecated code and extra stuff that makes it hard to reason about if you're new to this.
// https://github.com/pmndrs/zustand/blob/fe47d3e6c6671dbfb9856fda52cb5a3a855d97a6/src/vanilla.ts#L57-L94
function createStore(createState) {
@hassam7
hassam7 / mapPromises.js
Created February 24, 2024 12:04 — forked from andrew8088/mapPromises.js
Managing Promise Concurrency in JavaScript
function mapPromises(args, callback, concurrency = 3) {
const { promise, resolve } = Promise.withResolvers();
const results = [];
let cursor = 0;
function next() {
if (cursor < args.length) {
const index = cursor++;
void callback(...args[index]).then(value => {
@hassam7
hassam7 / grokking_to_leetcode.md
Created August 19, 2023 22:03 — forked from tykurtz/grokking_to_leetcode.md
Grokking the coding interview equivalent leetcode problems

GROKKING NOTES

I liked the way Grokking the coding interview organized problems into learnable patterns. However, the course is expensive and the majority of the time the problems are copy-pasted from leetcode. As the explanations on leetcode are usually just as good, the course really boils down to being a glorified curated list of leetcode problems.

So below I made a list of leetcode problems that are as close to grokking problems as possible.

Pattern: Sliding Window

@hassam7
hassam7 / base64.js
Created March 24, 2022 09:43 — forked from surma/base64.js
const LOOKUP =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
export function encodeBase64(buffer) {
const view = new Uint8Array(buffer);
let out = [];
for (let i = 0; i < view.length; i += 3) {
const [b1, b2 = 0x10000, b3 = 0x10000] = view.subarray(i, i + 3);
out.push(
b1 >> 2,
/* jshint esversion: 6 */
// Solve the following prompts using recursion.
// 1. Calculate the factorial of a number. The factorial of a non-negative integer n,
// denoted by n!, is the product of all positive integers less than or equal to n.
// Example: 5! = 5 x 4 x 3 x 2 x 1 = 120
// factorial(5); // 120
var factorial = function(n) {
if (n < 0) return null;
@hassam7
hassam7 / GreenBox.tsx
Created October 2, 2021 13:09 — forked from mfal/GreenBox.tsx
Extend regular HTML Elements with React & TypeScript
// We extend from React.HTMLAttributes to get all the HTML attributes
// Don't extend React.HTMLProps!
export interface IGreenBoxProps extends React.HTMLAttributes<HTMLDivElement> {
title: string;
}
class GreenBox extends React.Component<IGreenBoxProps, void> {
public render() {
// If you don't spread children and title, the restProps
// still contain these props and compiler will say "no"
@hassam7
hassam7 / it-ebooks.md
Created April 19, 2021 23:28 — forked from baiwfg2/it-ebooks.md
Download ebooks as you want