Skip to content

Instantly share code, notes, and snippets.

Avatar

Sebastian Zapata Mardini Mardiniii

View GitHub Profile
@Mardiniii
Mardiniii / job-search-make-it-real.md
Last active Dec 2, 2020
Links from the Job Search - Make It Real talk.
View job-search-make-it-real.md

Técnicas para encontrar empleo como desarrollador Web

Definition

Search Criteria:

  • Modalidad
  • Compensación
  • Tipo de compañía
  • Tecnologías
@Mardiniii
Mardiniii / curl.md
Created Feb 14, 2019 — forked from subfuzion/curl.md
curl POST examples
View curl.md

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@Mardiniii
Mardiniii / adapter.rb
Created Jun 1, 2018
Design Patterns using Ruby
View adapter.rb
# Adaptee
class Hammer
def swing
'swing'
end
end
# Target
class Tool
def initialize(adapter)
@Mardiniii
Mardiniii / dip.rb
Last active May 30, 2018
Dependency Injection Principle: Entities must depend on abstractions not on concretions. It states that the high level module must not depend on the low level module, but they should depend on abstractions.
View dip.rb
# Violates DIP
class InvoiceNotifier
def initialize(invoice)
@invoice = invoice
end
def mail_notification
InvoiceMailer.new.send(@invoice)
end
@Mardiniii
Mardiniii / isp.rb
Last active May 30, 2018
Interface segregation principle: A client should never be forced to implement an interface that it doesn't use or clients shouldn't be forced to depend on methods they do not use.
View isp.rb
# Violates ISP
class Airplane
def load_luggage
end
def load_fuel
end
def take_off
end
@Mardiniii
Mardiniii / lsp.rb
Created May 28, 2018
Liskov Sustitution Principle: Let q(x) be a property provable about objects of x of type T. Then q(y) should be provable for objects y of type S where S is a subtype of T.
View lsp.rb
# Violates LSP
class Company
def hire_people
expand_the_team
end
def open_new_location
create_a_new_office
end
@Mardiniii
Mardiniii / ocp.rb
Last active May 30, 2018
Open-closed Principle: Objects or entities should be open for extension, but closed for modification.
View ocp.rb
# Violates OCP
class InvoiceNotifier
def initialize(invoice)
@invoice = invoice
end
def notify(channel)
case channel
when 'email'
send_email
@Mardiniii
Mardiniii / srp.rb
Created May 28, 2018
Single Responsability Principle: A class should have one and only one reason to change, meaning that a class should have only one job.
View srp.rb
# Violates SRP
class Invoice
def initialize(items, client)
@items = items
@client = client
@total = 0
end
def generate
@Mardiniii
Mardiniii / data_replication_problem.rb
Last active May 24, 2018
1st approach to solve data replication problem using Ruby.
View data_replication_problem.rb
require 'minitest/autorun'
# Problem
# https://softwareengineering.stackexchange.com/questions/153806/conflict-resolution-for-two-way-sync
# interface DB {
# String Get(String)
# void Set(String, String)
# []String Keys()
#
@Mardiniii
Mardiniii / searchFormHandler.js
Last active Apr 30, 2018
Code snippet for medium post
View searchFormHandler.js
$(document).ready(function() {
function parseResponse(resultsContainer, data) {
console.log(data);
const resultsAmount = data.pages.length
$(resultsContainer).html('');
if (resultsAmount > 0) {
$.each(data.pages, function(index, page) {
appendToResults(resultsContainer, page)
setResultsTitle(resultsAmount + " results found it for: " + data.input, 'green')