Skip to content

Instantly share code, notes, and snippets.

@ricardo0100
ricardo0100 / PhotoView.swift
Created August 15, 2020 15:20
Photo View with zoom and edges control in SwiftUI
import SwiftUI
struct PhotoView: View {
@State var scale: CGFloat = 1
@State var scaleAnchor: UnitPoint = .center
@State var lastScale: CGFloat = 1
@State var offset: CGSize = .zero
@State var lastOffset: CGSize = .zero
@State var debug = ""
@mariocesar
mariocesar / api.js
Created September 26, 2017 04:21
Axios single configured instance
import axios from "axios";
const singleton = Symbol();
const singletonEnforcer = Symbol();
function readCookie(name) {
const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
return (match ? decodeURIComponent(match[3]) : null);
}
//: HashMap data structure
public struct HashMap<Key: Hashable, Value> {
typealias Element = (key: Key, value: Value)
var arraySize: Int
var numberInserted = 0
var array: [Element?]
var loadFactor: Double {
return Double(numberInserted) / Double(arraySize)
}