Skip to content

Instantly share code, notes, and snippets.

Avatar

A. Matías Quezada amatiasq

View GitHub Profile
View interface-segregation.cs
using System;
// Interface segregation
interface ISimulationReporter<TResult>
{
event Action<TResult> OnComplete;
}
interface ISimulationRunner<TInput>
View netcode.test.ts
import { equal } from 'assert';
import { FIRST_FRAME } from './Netcode';
import { NetcodeClient } from './NetcodeClient';
import { NetcodeServer } from './NetcodeServer';
type UserId = 'a' | 'b';
type Input = 'RUN' | null;
interface Entity {
x: number;
View ts-mockito.ts
import { mock, instance, when, verify, anything } from 'ts-mockito';
const mockedFoo: Foo = mock(Foo);
// stub method before execution
when(mockedFoo.getBar(3)).thenReturn('three');
// Getting instance from mock
const foo: Foo = instance(mockedFoo);
View esm.ts
const extensions = {
js: 'application/javascript',
ts: 'application/typescript',
jsx: 'text/jsx',
tsx: 'text/tsx',
} as const;
type Extensions = typeof extensions;
type ValidExtension = keyof Extensions;
type ValidMediaType = Extensions[ValidExtension];
View concatRegexes.js
const createConcatenator = escape => (...regexes) => {
const join = regexes
.map(x => (x instanceof RegExp ? regexToString(x) : escape(x)))
.join("");
const flags = regexes
.map(x => x instanceof RegExp && x.flags)
.filter(Boolean)
.join("");
View typed-messaging.ts
interface Message<Type extends string | number, Data = never> {
type: Type;
data: Data;
}
type MessageData<
Msg extends Message<any, any>,
Type extends Msg['type']
> = Extract<Msg, { type: Type }>['data'];
View cached-request.js
let cache = null;
export function myCachedRequest() {
if (cache) {
return Promise.resolve(cache);
}
return fetch('potato.com/foo').then(x => {
cache = x;
return x
View add-time-parameter.js
let url = '';
a
.split('\n')
.map(x => {
if (!x) {
return x;
}
if (x.startsWith('- [Lesson ')) {
View Clean Code - Masterclass.md

Lesson 1 - Clean Code

  • 0:00 Event Presentation
  • 2:03 Presenter Introduces Uncle Bob
  • 3:41 Uncle Bob Introduction / My Tribe
  • 4:49 How Far is the Sun?
  • 10:52 Introduction to Clean Code
  • 12:21 The current Society works with Software
  • 19:47 Volkswagen case / Introduction to the Ethics of Software Development
  • 24:28 Why are Programmers so slow?
  • 32:13 What is a Clean Code?
@amatiasq
amatiasq / softwarecraftsmanship.json
Created Aug 21, 2020
Signers of Software Craftmanshift Manifesto (so far)
View softwarecraftsmanship.json
This file has been truncated, but you can view the full file.
[
{
"name": "Doug Bradbury",
"location": "Chicago, IL, USA"
},
{
"name": "Corey Haines",
"location": "Cleveland, OH"
},