Skip to content

Instantly share code, notes, and snippets.

View inoyakaigor's full-sized avatar
😎
😎

Igor «InoY» Zviagintsev inoyakaigor

😎
😎
View GitHub Profile
@inoyakaigor
inoyakaigor / read.md
Last active October 30, 2018 16:17
nginx certificate for chrome 58+

openssl req -x509 -nodes -new -keyout inoy.rambler.ru.key -out inoy.rambler.ru.crt -subj "/CN=inoy.rambler.ru" -reqexts SAN -extensions SAN -config <(cat /System/Library/OpenSSL/openssl.cnf <(printf '[SAN]\nsubjectAltName=DNS:inoy.rambler.ru')) -sha256 -days 3650

@inoyakaigor
inoyakaigor / XOR type.md
Last active October 9, 2018 16:14
Исключающее объединение типов в typescript

Взято отсюда microsoft/TypeScript#14094 (comment)

type Without<T, U> = { [P in Exclude<keyof T, keyof U>]?: never };
type XOR<T, U> = (T | U) extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U;

type NameOnly = { is: "NameOnly", name: string };
type FirstAndLastName = { is: "FirstAndLastName", firstname: string; lastname: string };
type Person = XOR<NameOnly, FirstAndLastName>;
let person: Person;
@inoyakaigor
inoyakaigor / recursion type.md
Last active August 9, 2018 13:08
Рекурсивный тип в Typescript

Recursive types

To define a recursive type, use this trick:

type JSONValue = string | number | boolean | JSONObject | JSONArray;

interface JSONObject {
    [x: string]: JSONValue;
}
@inoyakaigor
inoyakaigor / scheme.json
Created November 15, 2017 16:07
React dev tools chrome color scheme
{"displayName":"Chrome","base00":"#252525","base01":"#393f4c","base02":"#454d5d","base03":"#454D5D","base04":"#a38fb2","base05":"#b4a9cb","special00":"#69c0f5","special01":"#53eb8c","special02":"#df9950","special03":"#acb3d8","special04":"#07c5a7","special05":"#e9f4fe","special06":"#7d99b6","special07":"#6b6b6a","state00":"#ad710d","state01":"#475983","state02":"#ffffff","state03":"#475983","state04":"#00ff7f","state05":"#181d20","state06":"#b9cadb","hidden":true}
Pidors.findAll({
attributes: [[Sequelize.fn('COUNT', Sequelize.col('pidorid')), 'pidor_times'], 'pidorid'],
where: {chatid: 2000000002},
order: [['pidor_times', 'DESC']],
group: 'pidorid',
limit: 10
})
@inoyakaigor
inoyakaigor / index.js
Created April 27, 2017 17:39 — forked from svnlto/index.js
FileReader Promise Helper
const readFile = (file) => {
let reader = new global.FileReader();
return new Promise((resolve, reject) => {
reader.onload = (event) => {
file.data = event.target. result;
resolve(file);
};
reader.onerror = () => {
let appId = login = password = phone = ''
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
})
let asker = (variable, name) => () => rl.question(`Введите ${name}: `, answer => {
variable = answer
rl.close() // ЧТО Я ДОЛЖЕН ЗДЕСЬ НАПИСАТЬ?