Skip to content

Instantly share code, notes, and snippets.

View siukalov's full-sized avatar
🎒
w

Anton Siukalov siukalov

🎒
w
View GitHub Profile
@jamiewinder
jamiewinder / detectexternalclick.tsx
Created November 22, 2018 16:05
Portal-friendly external event detection
import React from 'react';
import { DetectExternalEvents } from './detectexternalevents';
const EXTERNAL_REACT_EVENTS = ['onMouseDown', 'onTouchStart'];
const EXTERNAL_DOM_EVENTS = ['mousedown', 'touchstart'];
export interface IDetectExternalClickProps {
component?: string;
onExternalClick: (event: Event) => void;
@pistonsky
pistonsky / HOW_TO_CODE_REVIEW.md
Last active May 11, 2018 08:22
How to code review

How to code review?

  • Review is a top-priority task. Review code soon as possible. It can help to avoid massive merge of PRs at the end of sprint and won’t waste time of team members, especially if tasks are related to each other.
  • First of all you should check if the changes are related to the task. There shouldn’t be a thing like “let me also add this stuff to this PR by the way”.
  • Initial PR comment should contain the link to corresponding trello card.
  • You should not only check the code, but also check if the modified component is working correctly in the app. You check the code very carefully, every line. When checking the component in the app, you should test all possible use cases.
  • The code should follow established code style and styled with prettier. Also, please follow English language rules and use common sense when naming variables. Do not repeat yourself, but keep it simple.
  • Code review is not for critics, it’s rather a place for common effort to make a better product. That’s why it is
@robertvunabandi
robertvunabandi / Calculator.js
Last active September 2, 2022 16:56
Simple calculator implementation using Finite State Machines.
"use strict";
class Calc {
constructor() {
this._setToBaseState();
}
_setToBaseState() {
// find static methods at end of Calc class
this.__FIRST = "0";
@hofmannsven
hofmannsven / README.md
Created December 6, 2017 00:32
Increase key repeat rate on macOS

Increase key repeat rate on macOS

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.

Source: https://apple.stackexchange.com/a/83923

@yangshun
yangshun / using-eslint-with-prettier.md
Last active March 22, 2023 13:50
Comparison between tools that allow you to use ESLint and Prettier together.
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
@straker
straker / README.md
Last active May 12, 2024 12:01
Basic Snake HTML and JavaScript Game

Basic Snake HTML and JavaScript Game

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.

Further Exploration

  • Score
  • When the snake eats an apple, the score should increase by one. Use context.fillText() to display the score to the screen
@robertpainsi
robertpainsi / commit-message-guidelines.md
Last active May 15, 2024 19:48
Commit message guidelines

Commit Message Guidelines

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
@guilhermepontes
guilhermepontes / shuffle.js
Last active October 29, 2023 01:41
Shuffle Array - JavaScript ES2015, ES6
// 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]
@xem
xem / readme.md
Last active May 11, 2024 23:57
Maths & trigonometry cheat sheet for 2D & 3D games

Conventions

  • 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

Degrees to radians

angleRad = angleDeg * Math.PI / 180;

@leipert
leipert / detectBrowserLanguage.js
Last active March 11, 2024 02:10 — forked from anonymous/detectBrowserLanguage.js
Detect browser language in javascript (utilizing lodash)
// 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'];