Skip to content

Instantly share code, notes, and snippets.

Matthias Buchetics mbuchetics

View GitHub Profile
@mbuchetics
mbuchetics / ContentView.swift
Created Jul 16, 2020
SwiftUI view lifecycle
View ContentView.swift
import SwiftUI
struct ContentView: View {
let items = ["a", "b", "c"]
var body: some View {
NavigationView {
List {
ForEach(items, id: \.self) { item in
NavigationLink(item, destination: DetailView())
View UIBezierPath+Smooth.swift
import Foundation
import CoreGraphics
import UIKit
extension UIBezierPath {
convenience init?(quadCurve points: [CGPoint]) {
guard points.count > 1 else { return nil }
self.init()
@mbuchetics
mbuchetics / Dates.swift
Created Mar 7, 2018
Swift date parsing for date-only dates
View Dates.swift
import Foundation
let json =
"""
{
"name": "Matthias",
"birthday": "2017-03-22"
}
"""
@mbuchetics
mbuchetics / codeableEnum.swift
Created Jun 30, 2017 — forked from reckenrode/codeableEnum.swift
Implement Codable on an enum
View codeableEnum.swift
struct User: Codable {
var name: String
var email: String
var id: String
var metadata: [String: MetadataType]
enum CodingKeys: String, CodingKey {
case name, email, id, metadata
}
}
@mbuchetics
mbuchetics / json.swift
Created Jun 30, 2017 — forked from reckenrode/json.swift
Decoding arbitrary JSON with the new Decoder in Swift 4
View json.swift
enum JSON: Decodable {
case bool(Bool)
case double(Double)
case string(String)
indirect case array([JSON])
indirect case dictionary([String: JSON])
init(from decoder: Decoder) throws {
if let container = try? decoder.container(keyedBy: JSONCodingKeys.self) {
self = JSON(from: container)
View QRCodeScannerViewController.swift
//
// QRCodeScannerViewController.swift
//
// Created by Matthias Buchetics on 09/09/16.
// Copyright © 2016 Matthias Buchetics. All rights reserved.
//
import AVFoundation
import UIKit
@mbuchetics
mbuchetics / README-Template.md
Created Aug 12, 2016 — forked from PurpleBooth/README-Template.md
A template to make good README.md
View README-Template.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisities

View backbone_pushstate_router.js
// Use absolute URLs to navigate to anything not in your Router.
// Only need this for pushState enabled browsers
if (Backbone.history && Backbone.history._hasPushState) {
// Use delegation to avoid initial DOM selection and allow all matching elements to bubble
$(document).delegate("a", "click", function(evt) {
// Get the anchor href and protcol
var href = $(this).attr("href");
var protocol = this.protocol + "//";
You can’t perform that action at this time.