Skip to content

Instantly share code, notes, and snippets.

View anettodev's full-sized avatar
👨‍💻

Antonio Netto anettodev

👨‍💻
View GitHub Profile
@anettodev
anettodev / Install RBENV
Last active May 29, 2020 22:51
RBENV steps installation
## Install rbenv
$ brew update && brew install rbenv ruby-build
## Install Ruby Version Choosed (2.6.5 it's the one I want)
$ rbenv install -v 2.6.5
$ rbenv global 2.6.5
## Check Ruby Version
$ ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin19]
@anettodev
anettodev / .zshrc
Created May 10, 2020 20:11
This mine .zshrc config file
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
[user]
name = Antonio Netto
email = tonis.04@gmail.com
[core]
excludesfile = /Users/anetto/.gitignore_global
editor = atom
ignorecase = false
[web]
browser = google-chrome
[color]
@anettodev
anettodev / HTTPStatusCode.swift
Created July 29, 2019 18:42 — forked from ollieatkinson/HTTPStatusCode.swift
HTTP status codes as a Swift enum.
/// This is a list of Hypertext Transfer Protocol (HTTP) response status codes.
/// It includes codes from IETF internet standards, other IETF RFCs, other specifications, and some additional commonly used codes.
/// The first digit of the status code specifies one of five classes of response; an HTTP client must recognise these five classes at a minimum.
enum HTTPStatusCode: Int, Error {
/// The response class representation of status codes, these get grouped by their first digit.
enum ResponseType {
/// - informational: This class of status code indicates a provisional response, consisting only of the Status-Line and optional headers, and is terminated by an empty line.
case informational
enum ItalianMenu {
case penne
case ravioli
case lasagna
}
let italianOrdersQueue = RestaurantOrders<ItalianMenu>()// instance with ItalianMenu Items
italianOrdersQueue.enqueue(item: .penne)
italianOrdersQueue.enqueue(item: .lasagna)
print(italianOrdersQueue.showCurrentQueue()) // [.penne, .lasagna]
enum SimpleMenu {
case fries
case burger
case xBurger
case hotdog
}
let ordersQueue = RestaurantOrders<SimpleMenu>()// This instance only accept SimpleMenu Items
ordersQueue.enqueue(item: .hotdog)
ordersQueue.enqueue(item: .fries)
ordersQueue.enqueue(item: .xBurger)
// Orders Protocol
protocol Orders {
associatedtype Item
func enqueue(item:Item)
func dequeue() -> Item?
func showCurrentQueue() -> [Item]
}
// RestaurantOrders class
class RestaurantOrders<Item>: Orders {
var items : [Item] = [Item]()
// Custom Protocol
protocol CustomAddable {
static func +(lhs: Self, rhs: Self) -> Self
}
// Sum 2 Numeric elements
func sum<T: CustomAddable>(x: T, y: T) -> T {
return x + y
}
// extending to work with the Custom Protocol
extension Int: CustomAddable {}
// Sum 2 Numeric elements
func sum<T: Numeric>(x: T, y: T) -> T {
return x + y
}
sum(3, 4.5) // result 7.5
@anettodev
anettodev / SumInt.swift
Last active April 8, 2019 17:10
simple integers sum() function in swift
// Sum 2 Int elements
func sum(x: Int, y: Int) -> Int {
return x + y
}