Skip to content

Instantly share code, notes, and snippets.

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 Jun 9, 2021
amazon-s3-design-principles
View amazon-s3-design-principles.md

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.

View SwiftNetworkRequestSample.swift
// File: APIService.swift
import Foundation
import Combine
enum APIServiceError: Error {
case responseError
case parseError(Error)
}
protocol APIRequestType {
View bumpme
Tue Mar 10 05:20:01 UTC 2020
View SwiftUI+HexColors.swift
//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
View npm-outdated-autoupdate-latest.sh
# 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 Jun 3, 2018
Facebook Scripting Tools
View fb-ads-removal.js
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!");
View Docker-sweets.md

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
View Extensions.swift
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) {
View Delayer.swift
/**
* 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
@mayoralito
mayoralito / NetworkHandler.swift
Created Nov 16, 2017
Basic usage of Router for Network calls
View NetworkHandler.swift
// Swift 3
// Alamofire 4
enum Router: URLRequestConvertible {
case updateUser(userId: Int, body:[String:Any])
var method: HTTPMethod {
switch self {
case . updateUser(_,_):
return .put