Skip to content

Instantly share code, notes, and snippets.

View chekit's full-sized avatar
👋

Anton Cherepov chekit

👋
View GitHub Profile
@chekit
chekit / stash_dropped.md
Created October 4, 2019 13:02 — forked from joseluisq/stash_dropped.md
How to recover a dropped stash in Git?

How to recover a dropped stash in Git?

1. Find the stash commits:

git log --graph --oneline --decorate ( git fsck --no-reflog | awk '/dangling commit/ {print $3}' )

This will show you all the commits at the tips of your commit graph which are no longer referenced from any branch or tag – every lost commit, including every stash commit you’ve ever created, will be somewhere in that graph.

@chekit
chekit / what-forces-layout.md
Created September 16, 2019 10:10 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

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.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@chekit
chekit / Index.html
Created July 2, 2019 10:25 — forked from meziantou/Index.html
Javascript - Record audio
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<h1>Audio</h1>
@chekit
chekit / gist:3d5b6ec6e8f6839baadf738b279bafa0
Created December 26, 2018 08:15 — forked from lttlrck/gist:9628955
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@chekit
chekit / detect-click-outside-component.ts
Created July 10, 2018 14:48
Detect if the click was made outside host component
import { Component, ElementRef, HostListener } from '@angular/core';
/**
* If we need to detect where was click made outside the hosting component, we can use the construction below
* Source: https://stackoverflow.com/a/40107009
*/
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
@chekit
chekit / get_unique.js
Last active March 14, 2018 09:11
reduces digits array from repeated items to unique items only
// Reduces digits array from repeated items to unique items only
const arr = [1, 2, 1, 1, 4, 5, 7, 8, 2];
const unique = arr.filter((item, index, arr) => index === arr.indexOf(item));
console.log(unique); // [1, 2, 4, 5, 7, 8]
// Alternative
const unique2 = Array.from(arr.reduce((acc, item) => acc.add(item), new Set()));
console.log(unique2); // [1, 2, 4, 5, 7, 8]
git tag -am "annotation goes here" tagname_goes_here # cut a tag
git tag -d tagname_goes_here # burn it
git tag -am "annotation goes here" tagname_goes_here # cut another tag
git push --tags # push tags to remote
git push origin :refs/tags/tagname_goes_here # delete tag from remote
@chekit
chekit / ng-replace.md
Last active September 26, 2017 15:24
replace AngularJS expressions with Angular expressions

*ngFor

Заменяет старый синтаксис ng-repeat="item in obj.items track by $index" или ng-repeat="item in items track by $index" на новый *ngFor="let item of obj.items; trackBy: trackById;" или *ngFor="let item of items; trackBy: trackById;"

Выражение:

ng-repeat="([a-zA-Z]*)\s+(in)\s+([a-zA-Z\.{1}().]*)\s+track by \$index"

Замена:

@chekit
chekit / android-studio-install.md
Created August 10, 2017 22:23
How to deal with android emulation on Windows

Решил проблему незапускающегося проекта следующим образом:

В пункте Install the Android Tools ограничился установкой Android Studio

В Android Studio в settings нужно

@chekit
chekit / debounce_throttle.js
Created August 5, 2017 11:23
Debounce and Throttle methods
/*
Debounce
*/
export function debounce(fn, time) {
let timeout = null;
return function () {
let context = this;
let args = arguments;