Skip to content

Instantly share code, notes, and snippets.

# 1. Build our Angular app
FROM node:alpine as builder
WORKDIR /app
COPY package.json package-lock.json ./
ENV CI=1
RUN npm ci
COPY . .
RUN npm run build -- --prod --output-path=/dist
@tannerlinsley
tannerlinsley / onWindowFocus.ts
Last active January 30, 2024 09:37
A utility function to detect window focusing without false positives from iframe focus events
type State = {
added: boolean;
interval: false | ReturnType<typeof setInterval>;
inFrame: boolean;
callbacks: Array<SetFocusedCallback>;
};
type EnrichedHTMLIFrameElement = HTMLIFrameElement & { ___onWindowFocusHandled: boolean };
type SetFocusedCallback = (focused?: boolean) => void;
// import fetch from 'isomorphic-unfetch';
const RETRIES = 5;
/**
* Example:
* global.fetch = fetchWithRetry;
*/
function fetchWithRetry(url, options) {
@iamcryptoki
iamcryptoki / vscode-update-permission-denied.txt
Created December 14, 2018 19:46
Fix Visual Studio Code update error "Could not create temporary directory: Permission denied" on macOS.
sudo rm -Rf ~/Library/Caches/com.microsoft.VSCode.ShipIt
sudo rm -Rf ~/Library/Caches/com.microsoft.VSCodeInsiders.ShipIt
@bndynet
bndynet / amd-cmd-umd-commonjs.md
Last active June 14, 2024 03:15
AMD、CMD、UMD、CommonJS

Over the years there’s been a steadily increasing ecosystem of JavaScript components to choose from. The sheer amount of choices is fantastic, but this also infamously presents a difficulty when components are mixed-and-matched. And it doesn’t take too long for budding developers to find out that not all components are built to play nicely together.

To address these issues, the competing module specs AMD and CommonJS have appeared on the scene, allowing developers to write their code in an agreed-upon sandboxed and modularized way, so as not to “pollute the ecosystem”.

AMD(Asynchromous Module Definition)

Asynchronous Module Definition (AMD) has gained traction on the frontend, with RequireJS being the most popular implementation.

Here’s module foo with a single dependency on jquery:

@faressoft
faressoft / javascript_deep_dive.md
Last active September 7, 2024 16:47
JavaScript Deep Dive to Crack The JavaScript Interviews
@gaboratorium
gaboratorium / isIE.js
Created June 6, 2017 12:43
Detect IE with JavaScript #ie #edge #js #javascript
// Forked from https://codepen.io/gapcode/pen/vEJNZN
// Get IE or Edge browser version
var version = detectIE();
if (version === false) {
document.getElementById('result').innerHTML = '<s>IE/Edge</s>';
} else if (version >= 12) {
document.getElementById('result').innerHTML = 'Edge ' + version;
} else {
@beldpro-ci
beldpro-ci / 01-filladb.sh
Created April 29, 2017 14:56
Initialization script for `postgre:alpine`
#!/bin/bash
# Immediately exits if any error occurs during the script
# execution. If not set, an error could occur and the
# script would continue its execution.
set -o errexit
# Creating an array that defines the environment variables
# that must be set. This can be consumed later via arrray
@parshap
parshap / node-modules-in-react-native.md
Last active August 4, 2024 07:39
Running Node Modules in React Native

Running Node Modules in React Native

How to use packages that depend on Node.js core modules in React Native.

See the [node-libs-react-native][node-libs-react-native] library as a convenience for implementing this method.

Node.js Core Modules