Skip to content

Instantly share code, notes, and snippets.

View quangDecember's full-sized avatar
💭
my new year resolution is to not force unwrapped optionals

Quang quangDecember

💭
my new year resolution is to not force unwrapped optionals
View GitHub Profile
@propertyWrapper
public struct AnyProxy<EnclosingSelf, Value> {
private let keyPath: ReferenceWritableKeyPath<EnclosingSelf, Value>
public init(_ keyPath: ReferenceWritableKeyPath<EnclosingSelf, Value>) {
self.keyPath = keyPath
}
@available(*, unavailable, message: "The wrapped value must be accessed from the enclosing instance property.")
public var wrappedValue: Value {
@b3ll
b3ll / ModelBoundViewWrapper.swift
Created November 15, 2019 01:35
ModelBoundViewWrapper.swift
//: A UIKit based Playground for presenting user interface
import SwiftUI
import UIKit
import PlaygroundSupport
public struct ObservedObjectWrapperView<Content: View, Model: ObservableObject>: View {
@ObservedObject public var model: Model
@chriseidhof
chriseidhof / collectionview.swift
Last active January 31, 2024 19:00
SwiftUI Flow Layout
//
// ContentView.swift
// DeleteMe
//
// Created by Chris Eidhof on 02.02.21.
//
import SwiftUI
/*
//
// ContentView.swift
// SwiftTalkAnimationLoader
//
// Created by Chris Eidhof on 30.07.19.
// Copyright © 2019 Chris Eidhof. All rights reserved.
//
import SwiftUI
final class Loader: BindableObject {
let didChange = PassthroughSubject<Data?, Never>()
var task: URLSessionDataTask!
var data: Data? = nil {
didSet {
didChange.send(data)
}
}
init(_ url: URL) {
@liaogang
liaogang / gist:5d50377c87a7e6b92e9b8a1b402c833b
Created March 5, 2019 10:49
iOS separate cookie handler for multi users
/*
How to set cookieAcceptPolicy for ephemeral NSURLSession https://stackoverflow.com/questions/27290234/how-to-set-cookieacceptpolicy-for-ephemeral-nsurlsession
Multiple NSHTTPCookieStorage in the same app https://stackoverflow.com/questions/27132606/multiple-nshttpcookiestorage-in-the-same-app
NSHTTPCookieStorage for same URL but different users https://stackoverflow.com/questions/37597250/nshttpcookiestorage-for-same-url-but-different-users
*/
@interface NSHTTPCookieStorage (applePrivateHeader)
-(id)_initWithIdentifier:(id)arg1 private:(BOOL)arg2;
@end
@astamicu
astamicu / Remove videos from Youtube Watch Later playlist.md
Last active May 3, 2024 16:46
Script to remove all videos from Youtube Watch Later playlist

UPDATED 22.11.2022

It's been two years since the last update, so here's the updated working script as per the comments below.

Thanks to BryanHaley for this.

setInterval(function () {
    video = document.getElementsByTagName('ytd-playlist-video-renderer')[0];

 video.querySelector('#primary button[aria-label="Action menu"]').click();
@tonysneed
tonysneed / Mac OS X: Open in Visual Studio Code
Last active March 27, 2024 10:02
Add a command to Finder services in Mac OSX to open a folder in VS Code
- Open Automator
- File -> New -> Service
- Change "Service Receives" to "files or folders" in "Finder"
- Add a "Run Shell Script" action
- Change "Pass input" to "as arguments"
- Paste the following in the shell script box: open -n -b "com.microsoft.VSCode" --args "$*"
- Save it as something like "Open in Visual Studio Code"
@ulhas
ulhas / package_framework.rb
Created March 21, 2016 09:28
Fastlane - private lane for 'package_framework`
desc "Zip and copy to right folder"
private_lane :package_framework do |lane|
if !lane[:framework]
raise "No framework specified!".red
end
if !lane[:version]
raise "No version specified!".red
end