Skip to content

Instantly share code, notes, and snippets.

View zaverden's full-sized avatar
💭
Do IT

Denis Zavershinskiy zaverden

💭
Do IT
View GitHub Profile
type NullPartial<T> = {
[P in keyof T]?: T[P] | null;
};
type Optional<T, K extends keyof T> = Omit<T, K> & NullPartial<T>;
function withOptional<TProps, TOpts extends Array<keyof TProps>>(
Wrapped: ComponentType<TProps>,
optionals: TOpts,
Placeholder: ComponentType<Optional<TProps, TOpts[number]>>,
): ComponentType<Optional<TProps, TOpts[number]>> {
@zaverden
zaverden / .bashrc
Created May 30, 2020 15:46
auto apply .nvmrc
#### apply .nvmrc if exists
p=$(realpath .)
t=".nvmrc"
until [ $p = '/' ]; do
if [ -f $p/$t ]; then
nvm use
break
fi
p=$(realpath $p/..)
done
@zaverden
zaverden / demo.html
Last active January 17, 2019 13:50
demo
<!doctype html>
<html lang="en">
<head>
<script>
(function (paramName, url) {
function hrefWithoutHash(anchor) {
var hashLength = anchor.hash.length;
return anchor.href.substring(0, anchor.href.length - hashLength);
}
@zaverden
zaverden / list.json
Created January 16, 2019 07:52
List of strings for demo
[
"Some value",
"Another value",
"More values"
]
@zaverden
zaverden / Page content (before patch)
Created December 24, 2018 06:29
OneNote patch content 500 error
====== Request ===================
GET https://graph.microsoft.com/v1.0/me/onenote/pages/1-3e7c1460680d4fe28501792ccda64915!119-304d54d6-d499-49f0-b231-cb3a9248e4e9/content?includeIDs=true
====== Response: Headers ===================
Cache-Control: private
Transfer-Encoding: chunked
Content-Type: text/html; charset=utf-8
ETag: "{b98bb127-0abe-02cc-2762-7864574b8342}{1}"
request-id: 17234428-8bb8-4937-b197-f1c605e39aa1
client-request-id: 17234428-8bb8-4937-b197-f1c605e39aa1
{
"requests": [
{
"id": "1",
"method": "PATCH",
"url": "/me/onenote/pages/{{ pageId }}/content",
"body": {
"value": [
{
"action": "insert",
<html lang="en-US">
<head>
<title>One more list</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="created" content="2018-09-24T13:29:00.0000000" />
</head>
<body data-absolute-enabled="true" style="font-family:Calibri;font-size:11pt">
<div id="div:{3e7c1460-680d-4fe2-8501-792ccda64915}{186}" style="position:absolute;left:48px;top:115px;width:624px">
<ul id="ul:{3e7c1460-680d-4fe2-8501-792ccda64915}{186}">
// nodejs v8.9.4
// yarn add evernote@2.0.5
const Evernote = require('evernote');
const client = new Evernote.Client({ token: 'put-your-token-here', sandbox: false });
const store = client.getNoteStore();
process.on('uncaughtException', (err) => {
console.log({ source: 'uncaughtException', err });
process.exit(1);
});
const moo = require('moo');
const Time = require('./time');
const parser = moo.compile({
VAR: {
match: /{[a-zA-Z_]\w*}/,
keywords: { PREDEF: ['{today}'] } // predefined keywords
},
OP: ['and', 'or', '+', 'at'],
DAY: {
CERTS_PATH="/path/to/certs"
HOST="my.example.com"
EMAIL="email@example.com"
DOCKER_SOCK="/var/run/docker.sock"
docker run \
--name nginx-proxy \
--detach=true \
--publish 80:80 \
--publish 443:443 \