Skip to content

Instantly share code, notes, and snippets.

View fedemartinm's full-sized avatar

Fede Martín fedemartinm

  • Buenos Aires, Argentina
View GitHub Profile
@fedemartinm
fedemartinm / data-generator-utility.md
Created February 3, 2023 07:21
A compact tool to create a series of objects from a specific template, iterating through the different values for each property

Data generator utility

I'm writing a minifier for lexical nodes. Writing unit tests and after taking a quick look at the options for generating test data (factory-girl, faker.js, casual.js, etc) I saw that there wasn't one that would allow me to quickly define different values per property and generate a list of objects that use those values.

I am sharing a small utility to generate a list of objects from a shape, that iterates through the different possibilities for each property.

type Shape<T> = {
  [key in keyof T]: any;
};
@fedemartinm
fedemartinm / ruby_overview.md
Last active May 27, 2020 06:47
Ruby at a glance

A quick overview of Ruby! Complete docs here.

Facts

  • Everything you manipulate is an object
  • Every object has a unique object identifier (objectId)
  • Arrays and Hashes are indexed collections, both accessible using a key.
  • Hash constructors define default values
  • Built-in /Regular Expressions/