Skip to content

Instantly share code, notes, and snippets.

View tanvirraj's full-sized avatar
🚢
coding

Tanvir Raj tanvirraj

🚢
coding
View GitHub Profile
// TODO: make `pages` optional and measure the div when unspecified, this will
// allow more normal document flow and make it easier to do both mobile and
// desktop.
import {
createContext,
useCallback,
useContext,
useEffect,
useMemo,
useRef,
@pesterhazy
pesterhazy / building-sync-systems.md
Last active May 10, 2024 22:12
Building an offline realtime sync engine

So you want to write a sync system for a web app with offline and realtime support? Good luck. You might find the following resources useful.

Overview articles

@rsms
rsms / cgroup2-cpu-limit.sh
Last active December 1, 2022 04:08
Example of limiting how much CPU a process can use in linux with cgroup2
#!/bin/sh
set -e
# Documentation and guides:
# https://docs.kernel.org/admin-guide/cgroup-v2.html
# https://lore.kernel.org/lkml/20160812221742.GA24736@cmpxchg.org/T/
# https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/managing_monitoring_and_updating_the_kernel/using-cgroups-v2-to-control-distribution-of-cpu-time-for-applications_managing-monitoring-and-updating-the-kernel
# remove if already exists
[ -e /sys/fs/cgroup/test1 ] && rmdir /sys/fs/cgroup/test1
@danielgross
danielgross / screenshot2pdf.py
Created November 19, 2022 15:41
Take screenshots of websites and place into PDF
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from PIL import Image
import io
import time
import os
import sys
import numpy as np
from fpdf import FPDF
@jacob-ebey
jacob-ebey / deferred-overview.md
Last active September 11, 2023 09:10
Deferred Overview

Remix Deferred

Remix Deferred is currently implemented on top of React's Suspense model but is not limited to React. This will be a quick dive into how "promise over the wire" is accomplished.

SSR + Hydration

It isn't rocket science, but a quick recap of how frameworks such as react do SSR:

  1. Load data
  2. Render the app
@vivekgalatage
vivekgalatage / Note Taking.md
Last active April 5, 2024 08:52
Note Taking details

Welcome to the wacky world of almost 30 years of web

All of the following values for the <script type=" ••• "> will cause inline or external JavaScript to execute:

Value Note
"" The default value of script.type (eg: no type attribute present)
"text/javascript" The official JavaScript MIME type
"application/javascript" Legacy MIME type from when semantics mattered
"text/x-javascript" Legacy MIME type from before JavaScript was accepted as a valid MIME type
@phpfour
phpfour / git-revert.md
Created January 17, 2024 14:19
How to use git to revert a committed file to an earlier version

To revert a committed file to an earlier version using Git, you can use the git checkout command. Here's how you can do it:

git checkout {{commit_hash}} -- {{file_path}}

Replace {{commit_hash}} with the hash of the commit you want to revert to, and {{file_path}} with the path to the file you want to revert.

For example, if you want to revert the file script.js to an earlier version with the commit hash abc123, you would run: