Skip to content

Instantly share code, notes, and snippets.

NPM Commands, Scripts, Life-cycle Phases

The following describes the behaviour of several npm commands, particularly w.r.t. the scripts that are run in each, for NPM version 6.5.0.

npm build <other-package-folder>

  1. npm run preinstall
  2. link binaries (node-gyp)
  3. for each bin command in other package:
@shindigira
shindigira / ANSI.md
Created March 1, 2024 21:25 — forked from fnky/ANSI.md
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Page Routing Demo</title>
<script type="module" defer>
import PageRouter from "./page-router.js";
import RouterLink from "./router-link.js";
@shindigira
shindigira / Sidebar.jsx
Created July 1, 2023 17:12 — forked from nimone/Sidebar.jsx
Retractable Sidebar Component purely in ReactJS and TailwindCSS
import { MoreVertical, ChevronLast, ChevronFirst } from "lucide-react"
import { useContext, createContext, useState } from "react"
const SidebarContext = createContext()
export default function Sidebar({ children }) {
const [expanded, setExpanded] = useState(true)
return (
<aside className="h-screen">
@shindigira
shindigira / Carousel.jsx
Created June 22, 2023 17:53 — forked from nimone/Carousel.jsx
Build a carousel component like instagram purely in ReactJS and TailwindCSS
@shindigira
shindigira / remove-rubber-band-web-apps-ios
Created June 4, 2023 08:37 — forked from amolk/remove-rubber-band-web-apps-ios
Remove rubberband scrolling from web apps on mobile safari (iOS)
<!DOCTYPE html>
<html>
<head>
<title>Remove rubberband scrolling from web apps on mobile safari (iOS)</title>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-touch-fullscreen" content="yes">
<meta id="extViewportMeta" name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<style>
html, body {margin: 0; padding: 0; overflow: hidden}

Demo

Context

useViewportScroll is a great way to create a parallax effect as the page scrolls. In some cases however, we only want to scroll when an element is in the viewport area.

So for example, if we have a "landscape" scene, and want to animate the Sun object only when it's in view, we start with our useViewportScroll implementation:

function Sun(props) {
 const { scrollY, scrollYProgress } = useViewportScroll();
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>DomContentLoaded</title>
<script>
let startTime = performance.now();
</script>
<link rel="shortcut icon" href="./github.svg" />
@shindigira
shindigira / reduce.ts
Created January 15, 2023 02:20
5 ways to implement reduce in TypeScript
// test data
const xs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
const add = (x: number, y: number) => x + y
const mult = (x: number, y: number) => x * y
// types
type Reducer<T, U> = (acc: U, x: T) => U
type Reduce = <T, U>(f: Reducer<T, U>, acc: U, xs: readonly T[]) => U
{
// 1. baseline
const reduce: Reduce = (f, acc, xs) => xs.reduce(f, acc)
  1. Open Automator.app
  2. Create new Quick Action
  3. Select Run AppleScript
  4. Add this:
set inputVolume to input volume of (get volume settings)
if inputVolume = 0 then
	set inputVolume to 100
	display notification "Volume set to 100" with title "✅ Microphone is on"