Skip to content

Instantly share code, notes, and snippets.

Francisco Javier fgarcia

Block or report user

Report or block fgarcia

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@fgarcia
fgarcia / ajv.js
Last active Feb 13, 2019
Central definition schema with AJV + dynamic definitions
View ajv.js
// 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
fgarcia / main.md
Last active Jan 22, 2019
Composition Root and Service Locator
View main.md

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('https://api.bank.com')
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
fgarcia / output.txt
Last active Oct 7, 2017
Reset EventEmitter2
View output.txt
> node test.js
Start test
Catch!
end
Start test
Catch!
Catch!
View gist:c232f12da4e7e99899a72d78982938ce
> npm --version
3.10.6
> node --version
v6.3.1
> jest --debug
jest version = 15.1.1
test framework = jasmine2
config = {
View gist:792add55aee5751ef32b

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
fgarcia / gist:61ae715aa5d8c3bcf2a3
Created Apr 26, 2015
multiple #yard gems #ruby
View gist:61ae715aa5d8c3bcf2a3
libraries = {}
gems = %w(poconf)
gems.each do |gem_name|
Gem.source_index.find_name(gem_name).each do |spec|
libraries[spec.name] ||= []
libraries[spec.name] << YARD::Server::LibraryVersion.new(spec.name, spec.version.to_s, nil, :gem)
end
end
YARD::Server::RackAdapter.setup
@fgarcia
fgarcia / gist:09667f7c88e12ea81412
Last active Aug 29, 2015
Some quick references for Event Sourcing
View gist:09667f7c88e12ea81412
Mathias Verraes is one of my first references for beginners of Event Sourcing, his blog is full of goodness. As starting video:
http://verraes.net/2014/03/practical-event-sourcing/
Some talks of Emanuele DelBono like
https://www.youtube.com/watch?v=Vn34CdkLa3g
http://de.slideshare.net/emadb/wroclove-rb
For a VERY basic start, Ruby focused:
https://ianunruh.com/2013/08/event-sourcing-ruby.html
@fgarcia
fgarcia / gist:0d115f9fbe002b5d6922
Created Feb 9, 2015
Play with include vs exclude
View gist:0d115f9fbe002b5d6922
module Temp
def say
p "hi Parent"
end
end
class Swap
include Temp
def say
@fgarcia
fgarcia / gist:4ce7d571b84d54338e9b
Created Feb 9, 2015
Delegation pitfals vs extend
View gist:4ce7d571b84d54338e9b
require 'delegate'
class Person
def greeting
'hello'
end
def speak
greeting
end
@fgarcia
fgarcia / gist:80449b6d2754e66f557d
Last active Aug 29, 2015
Hide all Virtus attributes
View gist:80449b6d2754e66f557d
require 'virtus'
module PersonAttributes
include Virtus.module
attribute :name, String
attribute :age, Integer
end
class PersonModel
You can’t perform that action at this time.