Skip to content

Instantly share code, notes, and snippets.

export function toLines(s1: Observable<{ toString() }>) {
let lines$ = new Subject<string>()
let acu = ''
next: x => {
acu += x.toString()
if (!acu.includes('\n')) return
let lines = acu.split('\n')
let last = lines.pop()
fgarcia / ajv.js
Last active February 13, 2019 14:20
Central definition schema with AJV + dynamic definitions
// Objective: Define all schema definitions within a single schema '$id: core'
// + add definitions dynamically
it.only('extend Ajv definitions', async () => {
let res
let core1 = {
$id: 'core',
definitions: {
first: {
type: 'object',
fgarcia /
Last active January 22, 2019 22:29
Composition Root and Service Locator

If a program needs to make an API call, it is very likely that there is an ApiClient class to make http requests.

let api = new ApiClient('')
let bank = new BankFacade(api)

Since I consider an http request as something very basic in any app, I like having this in my runtime

fgarcia / output.txt
Last active October 7, 2017 11:50
Reset EventEmitter2
> node test.js
Start test
Start test
> npm --version
> node --version
> jest --debug
jest version = 15.1.1
test framework = jasmine2
config = {
fgarcia / gist:792add55aee5751ef32b
Last active March 20, 2016 22:32
On Dry types

Should a dry type behave more like a Hash?

Goal: ease transition / refactoring of existing code base

Functions like .keys, .values, .map are missing

Having them would make Dry Structs/Values a perfect drop-in replacement for Hash objects

Maybe a standard mixin to "extend this dirty functionality" would be great Any reason why those functions are not provided? It would be the most Ruby idiomatic

fgarcia / gist:61ae715aa5d8c3bcf2a3
Created April 26, 2015 11:44
multiple #yard gems #ruby
libraries = {}
gems = %w(poconf)
gems.each do |gem_name|
Gem.source_index.find_name(gem_name).each do |spec|
libraries[] ||= []
libraries[] <<, spec.version.to_s, nil, :gem)
fgarcia / gist:09667f7c88e12ea81412
Last active August 29, 2015 14:16
Some quick references for Event Sourcing
Mathias Verraes is one of my first references for beginners of Event Sourcing, his blog is full of goodness. As starting video:
Some talks of Emanuele DelBono like
For a VERY basic start, Ruby focused:
fgarcia / gist:0d115f9fbe002b5d6922
Created February 9, 2015 14:51
Play with include vs exclude
module Temp
def say
p "hi Parent"
class Swap
include Temp
def say
fgarcia / gist:4ce7d571b84d54338e9b
Created February 9, 2015 10:02
Delegation pitfals vs extend
require 'delegate'
class Person
def greeting
def speak