Skip to content

Instantly share code, notes, and snippets.

View HelgaZhizhka's full-sized avatar
👁️‍🗨️

Olga Zhyzhka HelgaZhizhka

👁️‍🗨️
View GitHub Profile
@FranklinGuan
FranklinGuan / Codewars-4kyu-Human_readable_duration_format.js
Last active April 3, 2024 12:30
Human readable duration format 4kyu-Codewars
//Introduction
// Your task in order to complete this Kata is to write a function which formats a duration, given as a number of seconds, in a human-friendly way.
// The function must accept a non-negative integer. If it is zero, it just returns "now". Otherwise, the duration is expressed as a combination of years, days, hours, minutes and seconds.
// It is much easier to understand with an example:
// formatDuration(62) // returns "1 minute and 2 seconds"
// formatDuration(3662) // returns "1 hour, 1 minute and 2 seconds"
// For the purpose of this Kata, a year is 365 days and a day is 24 hours.
// Note that spaces are important.
function debounce(originalFn, timeoutMs) {
let timeout;
return (...args) => {
clearTimeout(timeout); // clear timeout every time the function is called
timeout = setTimeout(() => originalFn(...args), timeoutMs); // call the original function once "timeoutMs" ms after the last call have elapsed
};
}
// Creates a throttled function that only invokes "originalFn" at most once per every "delayMs" milliseconds
function throttle(originalFn, delayMs) {
let timeout; // timeout to keep track of the executions
return (...args) => {
if (timeout) { // if timeout is set, this is NOT the first execution, so ignore
return;
}
// this is the first execution which we need to delay by "delayMs" milliseconds
timeout = setTimeout(() => {
@artem78
artem78 / git_commands_help.md
Last active February 7, 2024 01:59
Шпаргалка по командам GIT

Git-logo

Заметки по наиболее часто используемым командам GIT для себя и не только

Подтянуть новые коммиты из удалённого репозитория

Или в чём разница между git pull и git fetch? Если совсем коротко, то:

git pull = git fetch + git merge
/* Styles for hiding the native checkbox */
input[type='checkbox'].check-custom {
top: 0;
left: 0;
width: 0;
height: 0;
opacity: 0;
filter: alpha(opacity=0);
position: absolute;
visibility: hidden;
@beardlessman
beardlessman / GIT-rename-branch
Created July 12, 2018 05:06
[Git] Переименование ветки (локально и удаленно)
git branch -m old_branch new_branch – переименовать локальную ветку
git push origin :old_branch – удалить старую ветку
git push --set-upstream origin new_branch – выгрузить новую ветку и "закрепить" ее за локальной веткой
@KRostyslav
KRostyslav / tsconfig.json
Last active July 19, 2024 09:40
tsconfig.json с комментариями.
// Файл "tsconfig.json":
// - устанавливает корневой каталог проекта TypeScript;
// - выполняет настройку параметров компиляции;
// - устанавливает файлы проекта.
// Присутствие файла "tsconfig.json" в папке указывает TypeScript, что это корневая папка проекта.
// Внутри "tsconfig.json" указываются настройки компилятора TypeScript и корневые файлы проекта.
// Программа компилятора "tsc" ищет файл "tsconfig.json" сначала в папке, где она расположена, затем поднимается выше и ищет в родительских папках согласно их вложенности друг в друга.
// Команда "tsc --project C:\path\to\my\project\folder" берет файл "tsconfig.json" из папки, расположенной по данному пути.
// Файл "tsconfig.json" может быть полностью пустым, тогда компилятор скомпилирует все файлы с настройками заданными по умолчанию.
// Опции компилятора, перечисленные в командной строке перезаписывают собой опции, заданные в файле "tsconfig.json".
@aschmelyun
aschmelyun / DetectScroll.vue
Created May 29, 2018 09:19
Detect scrolling to the bottom of a div in Vue.js
<template>
<div class="wrapper">
<div class="box" @scroll="handleScroll">
<p>Your content here...</p>
</div>
<a href="#" v-if="hasScrolledToBottom">Show After Scrolling</a>
</div>
</template>
<script>
export default {
@bradonomics
bradonomics / overlay.css
Last active March 15, 2020 16:42
Background dark overlay
box-shadow: 0 0 0 2000px rgba(0, 0, 0, 0.4) inset;
border-collapse: separate;
/* Notes on IE: https://caniuse.com/#feat=mdn-css_properties_box-shadow_inset */
@lukaszb
lukaszb / http.js
Last active May 15, 2019 02:49
es6 http client using fetch
import 'whatwg-fetch'
import Auth from './Auth';
import Url from 'url-parse';
const API_URL = process.env.API_URL
const http = {
get: get,
getAuthed: getAuthed,