Skip to content

Instantly share code, notes, and snippets.

View VoloshchenkoAl's full-sized avatar
🇺🇦

Alex VoloshchenkoAl

🇺🇦
View GitHub Profile
@VoloshchenkoAl
VoloshchenkoAl / how-to-add-image-to-gist.md
Created November 6, 2022 19:19 — forked from mroderick/how-to-add-image-to-gist.md
How to add an image to a gist

How to add an image to a gist

  1. Create a gist if you haven't already.
  2. Clone your gist:
    # make sure to replace `<hash>` with your gist's hash
    git clone https://gist.github.com/<hash>.git # with https
    git clone git@gist.github.com:<hash>.git     # or with ssh
@VoloshchenkoAl
VoloshchenkoAl / Empty
Last active November 10, 2022 01:02
Projector. Images
Images

Многие увидев #Задачка_28 — "о, так здесь же можно просто взять lodash.get". И были бы правы. Но сначала рассмотрим более креативные варианты решений

Первый вариант

Решение на позицию тех. лида 🙂

Написать конвертор путей в формат json-pointer. А потом использовать библиотеку, которая умеет доставать значения с объекта в новом формате.

Сылка на формат json-pointer— https://datatracker.ietf.org/doc/html/rfc6901

Спасибо Юре Ткаченко, мы сами про это не подумали.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
git branch beforeReset
git reset --soft <root>
git commit --amend
# Verify that the new amended root is no different
# from the previous branch state
git diff beforeReset
1. Set to default registry:
npm set registry https://registry.npmjs.org/
2. Unpublish package (force)
npm unpublish[<@scope>/]<pkg>[@<version>]
2.1. Force
npm unpublish <pkg> --force
3. Recompile C++ addons (if install new version of nodejs)+
у button всегда надо указывать type="button" иначе кнопка будет вести себя как type="submit"
/**
* relates an element's border box to the document origin
*
* @param {DOMObject} current element
* @return {Object} top and left cooridanets of element relative to origin document
*/
function offset(element) {
const rect = element.getBoundingClientRect();
const win = element.ownerDocument.defaultView;
// --------- Класс-Родитель ------------
// Конструктор родителя пишет свойства конкретного объекта
function Animal(name) {
this.name = name;
this.speed = 0;
}
// Методы хранятся в прототипе
Animal.prototype.run = function() {
alert(this.name + " бежит!")
class EventEmitter {
constructor() {
this.events = {};
}
emit(eventName, data) {
const event = this.events[eventName];
if( event ) {
event.forEach(fn => {
fn.call(null, data);