Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@vinczebalazs
vinczebalazs / KeyboardAvoidingViewController.swift
Created May 10, 2022 08:37
A simple UIViewController subclass that avoids the keyboard automatically.
import UIKit
class KeyboardAvoidingViewController: UIViewController {
private let margin: CGFloat = 20
private var keyboardFrame: CGRect?
override func viewDidLoad() {
super.viewDidLoad()
#!/usr/bin/env python
"""
A basic adaptive bot. This is part of the third worksheet.
"""
from api import State, util
import random, os
from itertools import chain
import joblib
import joblib
import pickle
import sklearn.inspection
import numpy as np
import pandas as pd
import os.path
rows = ["Pers Clubs A","Pers Clubs 10","Pers Clubs K","Pers Clubs Q","Pers Clubs J",
"Pers Diamonds A","Pers Diamonds 10","Pers Diamonds K","Pers Diamonds Q","Pers Diamonds J",
@vinczebalazs
vinczebalazs / NetworkingExample.swift
Last active November 7, 2022 07:55
Protocol and generic based networking example.
import Foundation
// Model.
struct Employee: Codable {
let id: Int
let name: String
}
@vinczebalazs
vinczebalazs / SheetModalPresentationController.swift
Last active January 9, 2023 23:02
SheetModalPresentationController.swift
import UIKit
final class SheetModalPresentationController: UIPresentationController {
// MARK: Private Properties
private let isDismissable: Bool
private let interactor = UIPercentDrivenInteractiveTransition()
private let dimmingView = UIView()
private var propertyAnimator: UIViewPropertyAnimator!
func constrainToEdges(of view: UIView) {
translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
leftAnchor.constraint(equalTo: view.leftAnchor),
topAnchor.constraint(equalTo: view.topAnchor),
rightAnchor.constraint(equalTo: view.rightAnchor),
bottomAnchor.constraint(equalTo: view.bottomAnchor)
])
}
titleLabel?.font = Fonts.font(.quicksand, weight: .bold, size: 14)
struct Fonts {
enum Weight: String {
case bold = "Bold"
case light = "Light"
case regular = "Regular"
case semiBold = "SemiBold"
}
enum Font: String {
static func font(_ name: Font, weight: Weight, size: CGFloat) -> UIFont {
UIFont(name: "\(name.rawValue)-\(weight.rawValue)", size: size)!
}
enum Weight: String {
case bold = "Bold"
case light = "Light"
case regular = "Regular"
case semiBold = "SemiBold"
}