Skip to content

Instantly share code, notes, and snippets.

View sewera's full-sized avatar

Blazej Sewera sewera

View GitHub Profile
@sewera
sewera / type-checking-rewrite-in-typescript.ts
Last active March 10, 2022 09:23
"Dev vs production type checking" rewrite in TypeScript
// Based on: https://gist.github.com/ericelliott/e2dd9cbe5c64e44d6122ba76ec7dbf55#file-dev-vs-production-type-checking-js
type Timestamp = number // Date.now() returns number, so type alias gives better documentation
// good type names provide good documentation
type Employee = {
name: string,
hireDate?: Timestamp,
title?: string,
}
@sewera
sewera / fs_impl_with_os_open.go
Created June 19, 2022 12:44
Go (Golang) - fs.FS implementation with a correct root directory, using default os.Open implementation, as opposed to os.DirFS("/"), which can produce unwanted behavior on some systems
// issue in context: https://github.com/golang/go/issues/44279#issuecomment-1159714960
type OsFilesystem struct{}
func (f *OsFilesystem) Open(name string) (fs.File, error) {
return os.Open(name)
}
// *OsFilesystem implements fs.FS
var _ fs.FS = new(OsFilesystem)
@sewera
sewera / issue-to-note.yml
Created February 22, 2023 17:50
Issue to note Github Action
name: Issue to note
concurrency: issue-to-note
on:
issues:
types: [opened, edited]
jobs:
run:
runs-on: ubuntu-latest