Skip to content

Instantly share code, notes, and snippets.

View dandgerson's full-sized avatar
⚛️
what the actual hell happens in this damn component

Dmitry Anderson dandgerson

⚛️
what the actual hell happens in this damn component
View GitHub Profile
@panzerdp
panzerdp / decoratedFetch.ts
Last active September 18, 2022 23:51
An extensible fetch() implementation that uses the decorator pattern
type ResponseWithData = Response & { data?: any };
interface Fetcher {
run(input: RequestInfo, init?: RequestInit): Promise<ResponseWithData>;
}
class BasicFetcher implements Fetcher {
async run(input: RequestInfo, init?: RequestInit): Promise<ResponseWithData> {
return await fetch(input, init);
}
@Haraldson
Haraldson / usage.js
Last active March 11, 2023 13:53
Lodash useDebounce React Hook
import React, { useState, useEffect } from 'react'
import { useDebounce } from './use-debounce'
const MySearchComponent = props => {
const [search, setSearch, {
signal,
debouncing
}] = useDebounce('')
const [results, setResults] = useState([])
@ikiselev1989
ikiselev1989 / bem-and-sass.md
Last active April 30, 2019 12:47 — forked from radist2s/bem-and-sass.md
BEM & SASS best practices

BEM & SASS best practices

Every block should be in separated file named as block.

Filename: rating-star.scss

.rating-star {
    $font-size: 0.5em;
    
    display: inline-block; // `display` style may be set freely
@gaearon
gaearon / minification.md
Last active March 4, 2024 12:45
How to Set Up Minification

In production, it is recommended to minify any JavaScript code that is included with your application. Minification can help your website load several times faster, especially as the size of your JavaScript source code grows.

Here's one way to set it up:

  1. Install Node.js
  2. Run npm init -y in your project folder (don't skip this step!)
  3. Run npm install terser

Now, to minify a file called like_button.js, run in the terminal:

@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active April 25, 2024 16:04
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@agragregra
agragregra / scroll-top.html
Last active December 25, 2022 19:51
Scroll Top Button
<div class="top" title="Наверх"><i class="fa fa-angle-double-up"></i></div>
.top
position: fixed
bottom: 25px
background-color: #E0E0E0
border-radius: 10em
color: #666
font-size: 26px
width: 50px
@agragregra
agragregra / button.sass
Last active April 2, 2024 12:36
Button Sass Styles (Universal Starter)
.button
display: inline-block
border: none
color: #fff
text-decoration: none
background-color: $accent
padding: 15px 45px
font-size: 13px
text-transform: uppercase
font-weight: 600
@agragregra
agragregra / scroll-next.js
Created August 5, 2016 09:01
jQuery Scroll To Next Section
$(".scroll-next").click(function() {
var cls = $(this).closest(".section").next().offset().top;
$("html, body").animate({scrollTop: cls}, "slow");
});
'use strict';
// Требует node.js и пакета mkdirp
// Пакет mkdirp: https://www.npmjs.com/package/mkdirp#install — установить глобально или прописать установку в package.json, в секции devDependencies
// Использование:
// - поместить этот файл в корень проекта
// - исправить пути к генерируемым папкам и файлам, если блоки проекта лежат не в ./src/blocks/
// - в терминале, будучи в корневой папке проекта, выполнить node createBlock.js [имя блока] [доп. расширения через пробел]
const fs = require('fs'); // будем работать с файловой системой
@escapedcat
escapedcat / package.json
Last active May 16, 2018 09:39
npm scripts including node-sass and autoprefixer
{
"name": "foo",
"version": "1.0.0",
"description": "foo project",
"main": "index.js",
"scripts": {
"start": "npm run serve | npm run watch-css",
"serve": "./node_modules/.bin/http-server -p 8080",
"build-css": "./node_modules/node-sass/bin/node-sass app/sass/style.scss -o app/css/ && ./node_modules/postcss-cli/bin/postcss --use autoprefixer app/css/style.css -d app/css/",
"watch-css": "nodemon -e scss -x 'npm run build-css'"