Skip to content

Instantly share code, notes, and snippets.

View moatorres's full-sized avatar
👋

Moa Torres moatorres

👋
  • 04:13 (UTC -03:00)
View GitHub Profile
@pauloafpjunior
pauloafpjunior / !error-handling.ts
Last active February 15, 2022 06:14
Error handling in TypeScript: an alternative approach
// Value object
class CityName {
static readonly MIN_LEN_NAME: number = 3
static readonly MAX_LEN_NAME: number = 100
private constructor(private _name: string) { }
// Factory method with validation rules
static create(name: string): [CityName, Error] {
@pauloafpjunior
pauloafpjunior / !clean-arch.ts
Last active February 15, 2022 06:14
The simplest clean architecture example
namespace Domain {
export class Hero {
private constructor(private _name: string) { }
get name(): string { return this._name; }
static create(name: string): [Hero, Error] {
if (!name || name.trim().length < 3 || name.trim().length > 100) {
return [null, new InvalidNameError(name)]
}
[
{
"code": 100,
"name": "Continue",
"enum": "CONTINUE",
"reference": {
"info": "RFC 7231, Section 6.2.1",
"url": "https://tools.ietf.org/html/rfc7231#section-6.2.1"
},
"description": "The server has received the request headers and the client should proceed to send the request body",
@timscottbell
timscottbell / remove-resource-requests.js
Last active March 19, 2024 23:28
Remove resource requests
import {execSync} from 'child_process';
function main() {
const stdout = execSync(
"kubectl get deployment --all-namespaces --selector=projectCustomer=yes | awk '{print $1,$2}' | tail -n +2",
);
const results = stdout
.toString()
.split(/\n/)