Skip to content

Instantly share code, notes, and snippets.

View karudo's full-sized avatar

Deonis Peretyagin karudo

  • Batumi, Georgia
View GitHub Profile
@karudo
karudo / get-by-path.ts
Last active May 30, 2021 08:08
typescript get
type ExtractObj<S extends object, K> = K extends keyof S ? S[K] : never
type Path<S extends object, T extends readonly unknown[]> =
T extends readonly [infer T0, ...infer TR]
? TR extends []
? ExtractObj<S, T0> extends never
? readonly []
: readonly [T0]
: ExtractObj<S, T0> extends object
? readonly [T0, ...Path<ExtractObj<S, T0>, TR>]
@karudo
karudo / difference.js
Created March 5, 2021 05:04 — forked from Yimiprod/difference.js
Deep diff between two object, using lodash
/**
* Deep diff between two object, using lodash
* @param {Object} object Object compared
* @param {Object} base Object to compare with
* @return {Object} Return a new object who represent the diff
*/
function difference(object, base) {
function changes(object, base) {
return _.transform(object, function(result, value, key) {
if (!_.isEqual(value, base[key])) {
import {
EditorState,
ContentBlock,
genKey
} from 'draft-js';
import { List, Map } from 'immutable';
export const getSelectionRange = () => {
const selection = window.getSelection();
@karudo
karudo / draftjs-force-selection.js
Created May 14, 2020 17:13 — forked from tomcask/draftjs-force-selection.js
Example of force selection in draftjs
const getEditorState = this.props.store.getItem('getEditorState');
const setEditorState = this.props.store.getItem('setEditorState');
const selection = this.props.store.getItem('lastSelection');
const editorState = getEditorState();
const updateSelection = new SelectionState({
anchorKey: selection.anchorKey,
anchorOffset: selection.anchorOffset,
focusKey: selection.anchorKey,
focusOffset: selection.focusOffset,
isBackward: false,
import React, { useContext } from 'react';
import { PWRouterContext } from './context';
class MyClassComponent extends React.Component {
static contextType = PWRouterContext;
render() {
const {
routeName, // e.g. 'groupApplicationPermissions'
branch, // e.g [{name: 'root', path: 'v2'}, {name: 'aplicationsIndex', path: 'applications'}]
@karudo
karudo / index.css
Created December 27, 2018 09:00 — forked from stereokai/index.css
Trigonometry in CSS
//----------------------------------*\
// TRIGONOMETRY FUNCTIONS
//----------------------------------*/
// # Trigonometry in CSS
//
// - Through Taylor/Maclaurin polynomial representation: http://people.math.sc.edu/girardi/m142/handouts/10sTaylorPolySeries.pdf
// - Useful if you don't want to use JS.
// - With CSS Variables.
// - `calc()` can't do power (x ^ y) so I used multiplication instead.
const VERSION = self.LENTA_SW_VERSION;
const CACHE_FILES = [
'/assets/offline/index.html',
'/assets/offline/offline.css',
'/assets/offline/vendors.js',
'/assets/offline/offline.js',
'/assets/offline/offline.sprite.svg',
'/assets/offline/fonts/pt_sans-bold.woff2',
'/assets/offline/fonts/pt_sans-regular.woff2',
'/assets/offline/fonts/pt_sans-caption-regular.woff2',
const HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
configureWebpack: {
plugins: [new HtmlWebpackPlugin({
filename: 'test.html',
excludeChunks: ['app']
})],
entry: {
app2: './src/app2.js'
}

Keybase proof

I hereby claim:

  • I am karudo on github.
  • I am karudo (https://keybase.io/karudo) on keybase.
  • I have a public key ASCYrHhqzxNabbqGeLJlNH7_hdA2UArdEXMncX4mIymhzwo

To claim this, I am signing this object: