Skip to content

Instantly share code, notes, and snippets.

View tanvirraj's full-sized avatar
🚢
coding

Tanvir Raj tanvirraj

🚢
coding
View GitHub Profile
@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:

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
@vivekgalatage
vivekgalatage / Note Taking.md
Last active September 7, 2023 11:48
Note Taking details
@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
@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
@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
@pesterhazy
pesterhazy / building-sync-systems.md
Last active March 28, 2024 10:54
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

// 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,
@sindresorhus
sindresorhus / esm-package.md
Last active March 28, 2024 17:11
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.