Skip to content

Instantly share code, notes, and snippets.

View Lascorbe's full-sized avatar
👋
Hi there!

Luis Ascorbe Lascorbe

👋
Hi there!
View GitHub Profile
@Lascorbe
Lascorbe / ContentView.swift
Created July 31, 2023 09:41 — forked from dkun7944/ContentView.swift
AirDrop iOS 17 Swift.Shader Animation
//
// ContentView.swift
// Airdrop Demo
//
// Created by Daniel Kuntz on 7/30/23.
//
import SwiftUI
struct ContentView: View {
let subject = PassthroughSubject<Int, Never>()
let cancellable = subject
.scan((nil, nil)) { previous, current in
(previous.1, current)
}
.drop(while: {
// Why does the `drop(while:)` never return true here when Optional(1) == Optional(1)? Is this a bug?
if $0.0 == $0.1 {
return true
import UIKit
import SwiftUI
final class LoginViewController: UIHostingController<LoginView> {
private let viewModel: LoginViewModel
init(viewModel: LoginViewModel) {
self.viewModel = viewModel
super.init(rootView: LoginView(viewModel: viewModel))
}
import SwiftUI
import PlaygroundSupport
class Presenter: ObservableObject {
@Published var viewModel: ViewModel
private var timer: Timer!
private var memoryAddress: String!
init(prefix: String) {
@Lascorbe
Lascorbe / closure_copy
Last active December 15, 2015 12:09
Closure copy (Disclaimer: I don't need to do this, I just want to know if it's possible :))
// OBJC
@property (nonatomic, copy) MyBlock myBlock;
- (void)makeSomethingWithCompletionBlock:(MyBlock)completionBlock
{
self.myBlock = completionBlock;
}
// SWIFT
// Option without self
class Foo1 {
private let controller: UIViewController = {
return UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController()!
}()
private lazy var window: UIWindow = {
let window = UIWindow(frame: UIScreen.mainScreen().bounds)
window.backgroundColor = UIColor.whiteColor()
window.makeKeyAndVisible()
@Lascorbe
Lascorbe / swift_2_guided_tour_solutions.swift
Last active June 11, 2016 23:44
Swift 2 Guided Tour - Solutions
/****************/
/* A Swift Tour */
/****************/
//
// This file contains all the solutions (I made) to the "A Swift Tour" exercises
// found in "The Swift Programming Language", you can find that guide here:
// https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/GuidedTour.html#//apple_ref/doc/uid/TP40014097-CH2-ID1
//
// All examples are written using Swift 2.0 and Xcode 7
// HACK, but not critical if it fails.
+ (UIPopoverController *)popoverControllerForObject:(id)object {
if (!PSIsIpad()) return nil;
UIPopoverController *popoverController = object;
#ifndef PSPDFKIT_DONT_USE_OBFUSCATED_PRIVATE_API
NSString *printInteractionControllerKeyPath = [NSString stringWithFormat:@"%1$@%2$@.%1$@%3$@%4$@%5$@.%6$@%5$@", @"print", @"State", @"Panel", @"View", @"Controller", @"pover"];
@try {
if ([object isKindOfClass:UIPopoverController.class]) {
@Lascorbe
Lascorbe / facebook_meesenger_licenses.md
Last active December 28, 2015 07:29
Third party software/code used by the Facebook Messenger app (iOS)
# Load .profile, containing login, non-bash related initializations.
source ~/.profile
# Load .bashrc, containing non-login related bash initializations.
source ~/.bashrc
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*