Skip to content

Instantly share code, notes, and snippets.

View martincalvert's full-sized avatar

Martin martincalvert

View GitHub Profile
@martincalvert
martincalvert / deployment.yml
Last active October 25, 2017 15:47
K8s: Deployments
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: {{ .Chart.Name }}
labels:
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
spec:
replicas: {{ .Values.api.replicas }}
template:
metadata:
@martincalvert
martincalvert / days_between_dates.swift
Created August 22, 2017 18:26
Swift Difference Between Dates
//: Playground - noun: a place where people can play
import Foundation
let now = Date()
let future = Date(timeIntervalSinceNow: TimeInterval(1000000))
let currentCalendar = Calendar.current
let calendarScale: Set<Calendar.Component> = [.day, .hour, .minute]
let difference = currentCalendar.dateComponents(calendarScale, from: now, to: future)
print("Days: \(difference.day!) Hours: \(difference.hour!) Seconds: \(difference.minute!)")
@martincalvert
martincalvert / Xcode_Playground_URLSession.swift
Last active November 7, 2021 15:13
How to run URLSession requests in the playground in XCode 8.3
//: Playground - noun: a place where people can play
import Foundation
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
var request = URLRequest(url: URL(string: "https://api.github.com/")!)
request.httpMethod = "GET"
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data, error == nil else {