Skip to content

Instantly share code, notes, and snippets.

View mayoralito's full-sized avatar
:octocat:
This is the way!

amayoral mayoralito

:octocat:
This is the way!
View GitHub Profile
@mayoralito
mayoralito / amazon-s3-design-principles.md
Last active June 9, 2021 04:33
amazon-s3-design-principles

Amazon S3 Design Principles

The following principles of distributed system design were used to meet Amazon S3 requirements:

Decentralization: Use fully decentralized techniques to remove scaling bottlenecks and single points of failure.

Asynchrony: The system makes progress under all circumstances.

Autonomy: The system is designed such that individual components can make decisions based on local information.

Local responsibility: Each individual component is responsible for achieving its consistency; this is never the burden of its peers.

// File: APIService.swift
import Foundation
import Combine
enum APIServiceError: Error {
case responseError
case parseError(Error)
}
protocol APIRequestType {
Tue Mar 10 05:20:01 UTC 2020
//Trying out a prefix operator
//I thought vertical elipses made sense, representative of rbg
prefix operator ⋮
prefix func ⋮(hex:UInt32) -> Color {
return Color(hex)
}
extension Color {
init(_ hex: UInt32, opacity:Double = 1.0) {
let red = Double((hex & 0xff0000) >> 16) / 255.0
# Get all packages and save it to ENV variable
PACKAGES_TO_UPDATE=`npm outdated | awk '{print "npm install", $1"@latest", "--save; \n\r" }'`
# Save output to a location
echo $PACKAGES_TO_UPDATE > /tmp/npm-update-packages.log
# Open the file and remove the first line
# TODO: use awk to remove the first line of the file
vim /tmp/npm-update-packages.log
# Copy the content of the file and paste it on the terminal
# TODO: Create an script to get the output from npm outdated command and run the update against the latest version.
@mayoralito
mayoralito / fb-ads-removal.js
Last active June 3, 2018 17:33
Facebook Scripting Tools
function removeAds() {
var allItems = document.querySelectorAll('._2b2e ._2b2p');
for (var item of allItems) {
var isAdEnabled = (item.getAttribute('data-tooltip-content').toLowerCase() == "remove");
if (isAdEnabled) {
item.click();
}
}
}
console.log("Starting removing ads from facebook prefences!");

Run nginx with docker (Basic Config)

docker run -d -p 1234:80 \
-v /Users/{username}/local/path1/:/usr/share/nginx/html/ \
-v /Users/{username}/local/path2/:/usr/share/nginx/html/subpath1 \
-v /Users/{username}/local/path3/:/usr/share/nginx/html/subpath2 \
-v /Users/{username}/local/pathN/:/usr/share/nginx/html/subpath2/subfolder \
--name webserver \
nginx
import UIKit
// MARK: - UIColor
extension UIColor {
static func rbg(r: CGFloat, g: CGFloat, b: CGFloat) -> UIColor {
return UIColor(red: r/255, green: g/255, blue: b/288, alpha: 1)
}
convenience init?(hex: String, alpha: CGFloat = 1.0) {
/**
* MIT License
*
* Copyright (c) 2017-present, Adrian Mayoral.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is