Skip to content

Instantly share code, notes, and snippets.

View sanusart's full-sized avatar

Sasha Khamkov sanusart

View GitHub Profile
@sanusart
sanusart / color.js
Last active October 8, 2019 19:58
Light or dark hex color #color #hex
export const lightOrDark = (color, ratio = 155) => {
const hex = color.replace('#', '');
const red = parseInt(hex.substr(0, 2), 16);
const green = parseInt(hex.substr(2, 2), 16);
const blue = parseInt(hex.substr(4, 2), 16);
const brightness = (red * 299 + green * 587 + blue * 114) / 1000;
return brightness > ratio ? 'light' : 'dark';
};
@sanusart
sanusart / create_training_data.py
Last active August 29, 2019 20:44
Create training data #spacy #nlp
import spacy
from spacy.matcher import Matcher
from spacy.lang.en import English
nlp = English()
matcher = Matcher(nlp.vocab)
# create some patterns and add to matcher
pattern1 = [{"LOWER": "iphone"}, {"LOWER": "x"}]
pattern2 = [{"LOWER": "iphone"}, {"IS_DIGIT": True, "OP": "?"}]
@sanusart
sanusart / 0-readme.md
Last active November 9, 2022 10:45
Use custom icons in Antd v3 #antd #ant-design #icons #webpack

Ant design v3.9.0 custom svg icons and icons overrides

Why?

  • If you need to use material icons in your project for example.
  • If you need to add cusom icons

Preparations

File examples bellow

@sanusart
sanusart / demojs
Last active April 18, 2019 10:21
faker
import faker from 'faker';
export const dataStreamEntities = {
data: [
{
id: 6248,
name: 'Data Stream',
enabled: true,
sourceDisplayName: 'Google Analytics',
lastRunStatus: false,
@sanusart
sanusart / errors-cause.tsv
Last active March 31, 2019 16:23
errors cause #temp #tsv
ENTITY ORIGINAL_ERROR FRIENDLY_ERROR CAUSE POSSIBLE_ACTION RELEVANT_KB
dataStreams SOME_ERROR_345 Rate limit Rate limit happens when we try to process more than what the vendor allows for a certain time frame/account. Try to reprocess the data stream gradually https://localhost:3000/#/demo
reports SOME_ERROR_6788 not found Rate limit happens when we try to process more than what the vendor allows for a certain time frame/account. Try to reprocess the report gradually https://localhost:3000/#/demo
actions SOME_ERROR_89546 some error Rate limit happens when we try to process more than what the vendor allows for a certain time frame/account. Try to reprocess the action gradually https://localhost:3000/#/demo
workflows SOME_ERROR_123 unknown Rate limit happens when we try to process more than what the vendor allows for a certain time frame/account. Try to reprocess the workflow gradually https://localhost:3000/#/demo
@sanusart
sanusart / vvjij.tex
Last active April 6, 2019 11:59
text.tex
\begin{Bmatrix}
a & b \\
c & d
\end{Bmatrix}
\newline
\text{and}
\newline
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sanusart
sanusart / tsvToObject.js
Last active March 31, 2019 06:24
TSV to object #tsv #csv #lodash
export const tsvToObject = () =>
fetch('https://www.file.com/some.tsv')
.then(r => r.text())
.then(tsv => {
const data = compact(tsv.split('\n'));
const headers = head(data).split('\t');
const rows = map(row => row.split('\t'), tail(data));
return keyBy('SOME_HEADER', rows.map(m => zipObject(headers, m)));
});
@sanusart
sanusart / etszr.sql
Last active March 26, 2019 21:07
sql test #sql #temp #test #bug248
DECLARE
message varchar2(20):= 'Hello, World!';
BEGIN
dbms_output.put_line(message);
END;
/
@sanusart
sanusart / FiltersMenu.js
Last active March 24, 2019 05:09
FiltersMenu #temp
import React, { Component } from 'react';
import styled from 'styled-components/macro';
import GroupedBy from 'components/pages/Run/FiltersMenu/GroupedBy';
import { SegmentedButton, TextInput } from 'app-components';
import { ReactComponent as SuccessIcon } from 'assets/check.svg';
import { ReactComponent as ArrowRightIcon } from 'assets/arror_grey_toRight.svg';
const HEADER_HEIGHT = 65;