- A = [xA, yA] is a point on the 2D plane. Same for B, C, ...
- lengths are in any unit (ex: pixels)
- code snippets are in JavaScript
angleRad = angleDeg * Math.PI / 180;
// | |
// Regular Expression for URL validation | |
// | |
// Author: Diego Perini | |
// Created: 2010/12/05 | |
// Updated: 2018/09/12 | |
// License: MIT | |
// | |
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it) | |
// |
/* Polyfill indexOf. */ | |
var indexOf; | |
if (typeof Array.prototype.indexOf === 'function') { | |
indexOf = function (haystack, needle) { | |
return haystack.indexOf(needle); | |
}; | |
} else { | |
indexOf = function (haystack, needle) { | |
var i = 0, length = haystack.length, idx = -1, found = false; |
// These window.navigator contain language information | |
// 1. languages -> Array of preferred languages (eg ["en-US", "zh-CN", "ja-JP"]) Firefox^32, Chrome^32 | |
// 2. language -> Preferred language as String (eg "en-US") Firefox^5, IE^11, Safari, | |
// Chrome sends Browser UI language | |
// 3. browserLanguage -> UI Language of IE | |
// 4. userLanguage -> Language of Windows Regional Options | |
// 5. systemLanguage -> UI Language of Windows | |
var browserLanguagePropertyKeys = ['languages', 'language', 'browserLanguage', 'userLanguage', 'systemLanguage']; |
// original gist | |
const shuffleArray = arr => arr.sort(() => Math.random() - 0.5); | |
// fully random by @BetonMAN | |
const shuffleArray = arr => arr | |
.map(a => [Math.random(), a]) | |
.sort((a, b) => a[0] - b[0]) | |
.map(a => a[1]); | |
shuffleArray([1, 2, 3]) //[3, 1, 2] |
Short (72 chars or less) summary
More detailed explanatory text. Wrap it to 72 characters. The blank
line separating the summary from the body is critical (unless you omit
the body entirely).
Write your commit message in the imperative: "Fix bug" and not "Fixed
bug" or "Fixes bug." This convention matches up with commit messages
Snake is a fun game to make as it doesn't require a lot of code (less than 100 lines with all comments removed). This is a basic implementation of the snake game, but it's missing a few things intentionally and they're left as further exploration for the reader.
prettier-eslint |
eslint-plugin-prettier |
eslint-config-prettier |
|
---|---|---|---|
What it is | A JavaScript module exporting a single function. | An ESLint plugin. | An ESLint configuration. |
What it does | Runs the code (string) through prettier then eslint --fix . The output is also a string. |
Plugins usually contain implementations for additional rules that ESLint will check for. This plugin uses Prettier under the hood and will raise ESLint errors when your code differs from Prettier's expected output. | This config turns off formatting-related rules that might conflict with Prettier, allowing you to use Prettier with other ESLint configs like eslint-config-airbnb . |
How to use it | Either calling the function in your code or via [prettier-eslint-cli ](https://github.co |
Settings: System Preferences » Keyboard » Key Repeat/Delay Until Repeat
Use the commands below to increase the key repeat rate on macOS beyond the possible settings via the user interface. The changes aren't applied until you restart your computer.
"use strict"; | |
class Calc { | |
constructor() { | |
this._setToBaseState(); | |
} | |
_setToBaseState() { | |
// find static methods at end of Calc class | |
this.__FIRST = "0"; |