Skip to content

Instantly share code, notes, and snippets.

View freak4pc's full-sized avatar
🤓

Shai Mishali freak4pc

🤓
View GitHub Profile
//
// PaginationNetworkLogic.swift
//
// Created by Daniel Tartaglia on 4/9/17.
// Copyright © 2019 Daniel Tartaglia. MIT License
//
import RxSwift
struct PaginationUISource {
@IanKeen
IanKeen / Decodable+Random.swift
Last active March 29, 2022 13:06
Custom Decoder that can be used to create Decodable instances that are populated with random values
import Foundation
extension Decodable {
public static func randomInstance() throws -> Self {
let decoder = RandomDecoder()
return try Self(from: decoder)
}
}
private class RandomDecoder: Decoder {
@leoMehlig
leoMehlig / Keyframes.swift
Created October 17, 2019 16:00
Keyframe animations in SwiftUI
//
// Keyframes.swift
// Watch Extension
//
// Created by Leo Mehlig on 17.10.19.
// Copyright © 2019 Asana Rebel GmbH. All rights reserved.
//
import SwiftUI
// Copyright (c) 2019–20 Adam Sharp and thoughtbot, inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
@warpling
warpling / CAMediaTimingFunction.swift
Last active June 14, 2022 11:15
Better CAMediaTimingFunctions
//
// CAMediaTimingFunction.swift
import UIKit
extension CAMediaTimingFunction {
static let linear = CAMediaTimingFunction(name: .linear)
static let easeOut = CAMediaTimingFunction(name: .easeOut)
Hello,
I'd like to request the following information, in accordance with the information rights in the GDPR, and particularly Article 15. Please address all points in this email in turn.
1. A copy of all my personal data held and/or undergoing processing, in a commonly used electronic form (Article 15(3)). Please note that this might also include any audiovisual material (e.g. voice-recordings or pictures) and is not necessarily limited to the information contained in your customer database and/or the information you make available through the ‘manage my profile’ functionality. For all data that would fall under Article 20 (portability), I would like to recieve this in a commonly-used machine readable format. For data that does not fall under Article 20, such as data inferred about me or opinions about me, I would like this in a commonly-used electronic format.
2. If any data was not collected, observed or inferred from me directly, precise information about the source of that data, including the name and c
@dduan
dduan / SpeakBubble.swift
Last active June 20, 2020 13:56
Twitter's voice tweet UI has an interesting animation on iOS. This is an attempt to recreate that animation with SwiftUI. Looks like this https://youtu.be/I6XZzIgWYAQ
import SwiftUI
struct ChaoticPhoto: View {
let image: Image
let radius: CGFloat
@Binding var activated: Bool
@State var scale: CGFloat = 1
var body: some View {
image
.resizable()
@IanKeen
IanKeen / Usage.swift
Created July 24, 2020 18:47
SwiftUI: Show a sheet based on an optionals unwrapped value
@main
struct MyApp: App {
enum Sheet { case first, second }
@State var sheet: Sheet? = nil
var body: some Scene {
WindowGroup {
VStack {
Button("First") { sheet = .first }
extension UIHostingController {
convenience public init(rootView: Content, ignoreSafeArea: Bool) {
self.init(rootView: rootView)
if ignoreSafeArea {
disableSafeArea()
}
}
func disableSafeArea() {
@noahsark769
noahsark769 / LoginViewController.swift
Created December 29, 2020 20:03
Copying WKWebView cookies into HTTPCookieStorage
extension LoginViewController: WKNavigationDelegate {
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
if let url = webView.url, url.absoluteString.contains("/index.action") {
let store = WKWebsiteDataStore.default().httpCookieStore
store.getAllCookies { cookies in
if let sessionIdCookie = cookies.first(where: { cookie in
cookie.name == "JSESSIONID"
}) {
HTTPCookieStorage.shared.setCookies(cookies, for: webView.url, mainDocumentURL: nil)
self.callback(ConfluenceSessionCookie(jSessonId: sessionIdCookie))