Skip to content

Instantly share code, notes, and snippets.

View zyishai's full-sized avatar
🏠
Working from home

Yishai Zehavi zyishai

🏠
Working from home
  • Israel
View GitHub Profile
@zyishai
zyishai / README.md
Last active December 11, 2024 16:28
TypeScript Combinators

Summary

This RFC proposes a library of point-free functional combinators in TypeScript that leverage native TypeScript types. By reinterpreting existing types (null, undefined, never, arrays, etc.) in a functional context, we can build a lightweight, non-intrusive API that integrates seamlessly with existing TypeScript codebases.

Maybe

A Maybe type in ts-combinators is a regular TypeScript type, such as: Number, String, Boolean etc that is defined as follows:

type Empty = null | undefined | void | never;

Conventional Commit Messages

See how a minor change to your commit message style can make a difference.

Tip

Have a look at git-conventional-commits , a CLI util to ensure these conventions and generate verion and changelogs

Commit Message Formats

Default

@zyishai
zyishai / doc.md
Last active February 29, 2024 10:06
Handling authentication state

Handling authentication state

Server-based sessions

A session object is stored and managed on the server (e.g., in a database), and a generic session ID is stored in a cookie. Every time the user accesses the server, the cookie is parsed, and the session is retrieved from the server storage using the ID from the cookie.

This approach has many advantages: It prevents information leakage in case of a cookie theft because the cookie does not hold the session data itself. Also, session invalidation is simple: disassociate the session from the user in the database or even block the session in the database. Another advantage of this approach is the ability to store elaborate information about the user, such as client IP address, user agent, last login date, and more, all securely in your database (which, generally speaking, is more secure than a browser cookie).

The biggest disadvantage of this approach is the need to access the database for virtually every request. This can slow down the application and ev

@zyishai
zyishai / gist:ad2fe5a7ed9fcd6403d3e87ebc0de45d
Created December 18, 2023 16:34 — forked from koakh/gist:fbbc37cde630bedcf57acfd4d6a6956b
SurrealDB : How to use signin and signup (server + client nodesjs)
**As a developer you have complete control over the signup and signin functionality...**
```shell
$ surreal sql --conn http://localhost:8000 --user root --pass root --ns test --db test
```
```sql
-- optional : this is the default see --ns test --db test start server flags
-- USE NS test DB test;
@zyishai
zyishai / lolex.d.ts
Created October 31, 2018 13:30
Type definitions for Lolex 3
// Type definitions for lolex 3
// Project: https://github.com/sinonjs/lolex
// Definitions by: Wim Looman <https://github.com/Nemo157>
// Josh Goldberg <https://github.com/joshuakgoldberg>
// Rogier Schouten <https://github.com/rogierschouten>
// Yishai Zehavi <https://github.com/zyishai>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**
* Names of clock methods that may be faked by install.