Skip to content

Instantly share code, notes, and snippets.

View moatorres's full-sized avatar
👋

Moa Torres moatorres

👋
  • 18:46 (UTC -03:00)
View GitHub Profile
@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/)
[
{
"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",
@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)]
}
@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] {
@gvergnaud
gvergnaud / assigning-properties-in-typescript.ts
Last active June 27, 2021 15:59
Assigning properties to an Object type in TypeScript
/**
* # Assigning properties to an object type in TypeScript
*
* When we want to assign some properties on a object type
* we usually use the `&` operator:
*
* type B = A & { someProperty: string }
*
* It seems to work at first sight, but it doesn't behave exactly
* as we would expect when we try to override properties that already
@gvergnaud
gvergnaud / extends-in-typescript.ts
Last active June 27, 2021 15:59
How does the extends keyword work in typescript. Interactive playground: https://bit.ly/2XdCEfn
/**
* # How does `A extends B` work in TypeScript?
*
* If you think about types in terms of sets containing possible values,
* the `string` type is the set of all possible strings,
* the `number` type is the set of all possible numbers,
* the `'hello'` type is a set containing only the string 'hello'
* and the `2` type is a set containing only the number 2.
*
* Then you can think of `A extends B` as asking this question:
@jjcodes78
jjcodes78 / nextjs-deploy.md
Last active January 2, 2025 15:03
Deploying NEXTJS site with nginx + pm2

How to setup next.js app on nginx with letsencrypt

next.js, nginx, reverse-proxy, ssl

1. Install nginx and letsencrypt

$ sudo apt-get update
$ sudo apt-get install nginx letsencrypt

Also enable nginx in ufw

@kislayverma
kislayverma / steve-yegge-google-platform-rant.md
Created December 26, 2019 07:11
A copy (for posterity) of Steve Yegge's internal memo in Google about what platforms are and how Amazon learnt to build them

I was at Amazon for about six and a half years, and now I've been at Google for that long. One thing that struck me immediately about the two companies -- an impression that has been reinforced almost daily -- is that Amazon does everything wrong, and Google does everything right. Sure, it's a sweeping generalization, but a surprisingly accurate one. It's pretty crazy. There are probably a hundred or even two hundred different ways you can compare the two companies, and Google is superior in all but three of them, if I recall correctly. I actually did a spreadsheet at one point but Legal wouldn't let me show it to anyone, even though recruiting loved it.

I mean, just to give you a very brief taste: Amazon's recruiting process is fundamentally flawed by having teams hire for themselves, so their hiring bar is incredibly inconsistent across teams, despite various efforts they've made to level it out. And their operations are a mess; they don't really have SREs and they make engineers pretty much do everything,

@gadzhimari
gadzhimari / adobe_cc.md
Created November 22, 2018 11:29
Completely Remove Adobe from your Mac in 2 Steps

Step 1

Download and run the Adobe Creative Cloud Cleaner Tool, their multi-app uninstaller and wipe assistant. Adobe does recommend running individual application uninstallers first, your call. Click the Clean All option.

Step 2

Type a one line command in terminal find ~/ -iname "*adobe*" and it's shows up all files which match pattern.

To remove all files

`sudo rm -rf /Applications/Adobe* /Applications/Utilities/Adobe* /Library/Application\ Support/Adobe /Library/Preferences/com.adobe.* /Library/PrivilegedHelperTools/com.adobe.* /private/var/db/receipts/com.adobe.* ~/Library/Application\ Support/Adobe* ~/Library/Application\ Support/com.apple.sharedfilelist/com.apple.LSSharedFileList.ApplicationRecentDocuments/com.adobe* ~/Library/Application\ Support/CrashReporter/Adobe* ~/Library/Caches/Adobe ~/Library/Caches/com.Adobe.* ~/Library/Caches/com.adobe.* ~/Library/Cookies/com.adobe.* ~/Library/Logs/Adobe* ~/Librar

@ryandabler
ryandabler / Object property descriptors.js
Last active June 17, 2021 00:05
Complete example of an object defined using property descriptors for this article: https://itnext.io/enhancing-javascript-objects-with-descriptors-and-symbols-2cdc95e9b422
// Create "backend" object to hold data for getters and setters on main object
const _ = Object.create( null );
Object.defineProperties(
_,
{
firstname: {
value: 'John',
writable: true,
enumerable: false,