Skip to content

Instantly share code, notes, and snippets.

View smolijar's full-sized avatar
🐈‍⬛
I can has cheezburger?

Jaroslav Šmolík smolijar

🐈‍⬛
I can has cheezburger?
View GitHub Profile
@smolijar
smolijar / cs.json
Last active November 22, 2017 14:49
This file has been truncated, but you can view the full file.
[{"title":"hlavní","pos":"podstatné jméno, přídavné jméno","hyphenation":"hlav-ní","ethymology":"","meaning":""},{"title":"růže","pos":"","hyphenation":"rů-že","ethymology":"Z latinského rosa – růže.","meaning":"1) okrasná květina s]] [[trny 2) kožní nemoc (erysipel)"},{"title":"nádraží","pos":"podstatné jméno","hyphenation":"ná-dra-ží","ethymology":"","meaning":"1) staniční budova s]] [[přiléhajícím drážním zařízením, zpravidla s]] [[více kolejemi 2) účelová komunikace s]] počtem autobusových stání a]] [[s obslužným terminálem"},{"title":"být","pos":"sloveso","hyphenation":"být","ethymology":"","meaning":"1) existovat, vyskytovat se ve skutečném světě; zůstávat při životě 2) vyskytovat se ve skupině entit s]] [[vymezenými vlastnostmi 3) pomocné sloveso v trpném rodě 4) pomocné sloveso v minulém čase (pouze v 1. a 2. osobě) ve spojení s příčestím minulým 5) pomocné sloveso v budoucím čase nedokonavých sloves ve spojení s infinitivem 6) pomocné sloveso v kondcionálu 7) sponové sloveso 8) mít za téma"},{"title

❓ Finding return type for pipe

function pipe<D1, D2, D3, D4, D5, DRes, R1>(
    df: DeltaFn<D1, D2, D3, D4, D5, DRes>,
    r1: RiverFn<DRes, R1>
): ...?;

🤔 If we could just replace return type of a function type...

function pipe<D1, D2, D3, D4, D5, DRes, R1>(

Flow function type

👀 How lodash solves it?

It does not

  • long, unmaintainable, unconscious
  • junk code
  • limited number of args (usually 5 - 10)

💡 Intuitive code (that does not compile)

@smolijar
smolijar / isa_model_in_ts.md
Last active November 28, 2018 07:40
Isa model in Typescript

ISA model in TypeScript

😿 Lousy solution

export enum ServiceType {
    ServiceOperation = 'serviceOperation',
    BikeRent = 'bikeRent',
    OrderCharge = 'orderCharge',
}

export interface ServiceAttributes {
@smolijar
smolijar / tz_dates_mysql.md
Last active November 20, 2018 16:31
[TZ dates in MySQL]

Timezoned dates in MySQL 🐬

Problem 😿

Error: ER_TRUNCATED_WRONG_VALUE: Incorrect datetime value: '2017-10-10T06:50:04.006Z' for column 'created_at' at row 1

Solution 😺

MySQL config, e.g.: /etc/mysql/my.cnf

@smolijar
smolijar / omit_type.md
Last active November 28, 2018 09:20
omit_type
author tags
Jaroslav Šmolík
typescript
omit
meta type
generic type

Omit type and meta programming

Post entity

Typescript: Function composition and recurrent types

While I was working on our toolkit library Desmond I stumbled upon a problem when defining the TypeScript definition for a function pipe.

With help from Joe Calzaretta, a software developer working for MIT's IS&T, I defined type definitions for a variadic function composition in TypeScript, that is in some aspects superior to the existing solutions implemented in popular libraries.

Adapting the proposed solution I managed to define the HOC function type for composition without overloads, ultimately allowing it to safely type-check function chain for any number of arguments, which is a feature lacking in type definitions of even extremely popular utility libraries such as Lodash.

What is pipe?

Hlavni temata

  • Typescript - Jazyk ve kterem to popisuju (ma "TS" logo)
  • Kompozice funkci - To co popisuju. Je to prosty skladani funcki, ma zname notace g(f()) resp g ∘ f 
  • Rekurze - (~sebereference) Prostredek, kterym to popisuju

Vedlejsi temata

Hodne znamy knihovny, ktery to nejak popisujou a beru je jako referenci:

{
"editor.fontFamily": "'Firicico', 'monospace', monospace, 'Droid Sans Fallback'",
"editor.fontLigatures": true,
"editor.fontSize": 15.5,
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": [
//following will be in italics (=Pacifico)
// "comment",
This file has been truncated, but you can view the full file.
error: Extra semicolon (semi) at ../liam-api/src/app/components/authyWrapper.ts:1:32:
> 1 | import logger from 'app/logger';
| ^
2 | import * as authy from 'authy';
3 | import config from 'config/config';
4 |
error: Extra semicolon (semi) at ../liam-api/src/app/components/authyWrapper.ts:2:31:
1 | import logger from 'app/logger';