Skip to content

Instantly share code, notes, and snippets.

View dimensi's full-sized avatar
🏠
Working from home

Nikita Nafranets dimensi

🏠
Working from home
View GitHub Profile
@function pxToVw($px, $base: 1440) {
@return $px / 10 + rem;
}
$sizes: (
'headline64': (
font-size: 64,
font-weight: 500,
line-height: 1,
),
[generated bytecode for function: flatComments]
Parameter count 2
Frame size 40
713 E> 0x15d2a92ef412 @ 0 : a1 StackCheck
0x15d2a92ef413 @ 1 : 25 02 Ldar a0
0x15d2a92ef415 @ 3 : 99 06 JumpIfNotUndefined [6] (0x15d2a92ef41b @ 9)
0x15d2a92ef417 @ 5 : 78 00 CreateEmptyArrayLiteral [0]
0x15d2a92ef419 @ 7 : 87 04 Jump [4] (0x15d2a92ef41d @ 11)
0x15d2a92ef41b @ 9 : 25 02 Ldar a0
0x15d2a92ef41d @ 11 : 26 fb Star r0
<script>
function r(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min; //Максимум и минимум включаются
}
const m = r(7, 10)
const y = new Date().getFullYear() + 1
const d = r(1, 28)
@dimensi
dimensi / portal.js
Last active October 11, 2019 13:34
portals
import { createEvent, createStore } from 'effector'
import { useLayoutEffect } from 'react'
import { useStoreMap } from 'effector-react'
const portalSetted = createEvent()
const portalRemoved = createEvent()
const $portal = createStore({})
$portal
.on(portalSetted, (state, { destination, children }) => ({
...state,
@dimensi
dimensi / HTML2EditorJS.php
Created July 24, 2019 15:27
convert html to editor js readable format
<?php
use DOMDocument;
use DOMNode;
use DOMNodeList;
use Illuminate\Support\Collection;
final class HTML2EditorJS
{
private $document;
@dimensi
dimensi / index.html
Created April 7, 2019 09:11
Example for use editorjs without js bundlers
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Editor.js playground</title>
</head>
<body>
<div id="editor"></div>
version: '3'
services:
web:
image: nginx
volumes:
- ./.docker/conf/nginx/default.conf:/etc/nginx/conf.d/default.conf
- .:/var/www/html
ports:
- 5000:80
restart: always
@dimensi
dimensi / SwitchTransition.jsx
Last active March 12, 2019 15:07
Switch transition for react-transition-group
import React from 'react'
import PropTypes from 'prop-types'
function areChildrenDifferent (oldChildren, newChildren) {
if (oldChildren === newChildren) return false
if (
React.isValidElement(oldChildren) &&
React.isValidElement(newChildren) &&
oldChildren.key != null &&
oldChildren.key === newChildren.key
@dimensi
dimensi / Portal.js
Last active February 19, 2019 18:09
React portal on context api
import { useContext, useLayoutEffect } from 'react'
import { PortalContext } from './PortalContext'
export function Portal ({ to, children }) {
const { addTarget, removeTarget } = useContext(PortalContext)
useLayoutEffect(() => {
addTarget(to, children)
return () => {
removeTarget(to)
}
@dimensi
dimensi / utils.js
Last active January 21, 2019 09:37
getByPath function get
/**
*
* @param {object} obj
* @param {string} path
* @example ```js
getByPath(obj, 'a.c.b.0.c')
```
*/
export const getByPath = (obj, path) => {
if (obj == null) return null