- Enter plan mode for ANY non-trivial task (3+ steps or architectural decisions)
- If something goes sideways, STOP and re-plan immediately — don't keep pushing
- Use plan mode for verification steps, not just building
- Write detailed specs upfront to reduce ambiguity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| Compares two items (values or references) for nested equivalency, meaning that | |
| at root and at each key or index they are equivalent as follows: | |
| - If a value type, values are either hard equal (===) or are both NaN | |
| (different than JS where NaN !== NaN) | |
| - If functions, they are the same function instance or have the same value | |
| when converted to string via `toString()` | |
| - If Date objects, both have the same getTime() or are both NaN (invalid) | |
| - If arrays, both are same length, and all contained values areEquivalent |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function promiseMap(inputValues, mapper) { | |
| const reducer = (acc$, inputValue) => | |
| acc$.then(acc => mapper(inputValue).then(result => acc.push(result) && acc)); | |
| return inputValues.reduce(reducer, Promise.resolve([])); | |
| } | |
| /* Example */ | |
| const axios = require('axios'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fpsMeter() { | |
| let prevTime = Date.now(), | |
| frames = 0; | |
| requestAnimationFrame(function loop() { | |
| const time = Date.now(); | |
| frames++; | |
| if (time > prevTime + 1000) { | |
| let fps = Math.round( ( frames * 1000 ) / ( time - prevTime ) ); | |
| prevTime = time; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const http2 = require('http2'); | |
| const fs = require('fs'); | |
| const path = require('path'); | |
| const zlib = require('zlib'); | |
| const brotli = require('brotli'); // npm package | |
| const PORT = 3032; | |
| const BROTLI_QUALITY = 11; // slow, but we're caching so who cares | |
| const STATIC_DIRECTORY = path.resolve(__dirname, '../dist/'); | |
| const cache = {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Vue from 'vue' | |
| import axios from 'axios' | |
| import store from '../store' | |
| import { TokenService } from '../services/storage.service' | |
| // Full config: https://github.com/axios/axios#request-config | |
| let config = { | |
| baseURL: | |
| process.env.baseURL || |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| String.prototype.turkishtoEnglish = function () { | |
| return this.replace('Ğ','g') | |
| .replace('Ü','u') | |
| .replace('Ş','s') | |
| .replace('I','i') | |
| .replace('İ','i') | |
| .replace('Ö','o') | |
| .replace('Ç','c') | |
| .replace('ğ','g') | |
| .replace('ü','u') |
All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.
elem.offsetLeft,elem.offsetTop,elem.offsetWidth,elem.offsetHeight,elem.offsetParentelem.clientLeft,elem.clientTop,elem.clientWidth,elem.clientHeightelem.getClientRects(),elem.getBoundingClientRect()
NewerOlder