Skip to content

Instantly share code, notes, and snippets.

View ugommirikwe's full-sized avatar

Ugo ugommirikwe

View GitHub Profile
@dduan
dduan / RemoveDuplicates.swift
Created July 30, 2019 19:00
Combine framework: remove duplicates by key paths.
import Combine
@available(OSX 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
extension Publisher {
func removeDuplicates<Property>(by keyPath: KeyPath<Output, Property>)
-> Publishers.RemoveDuplicates<Self> where Property: Equatable
{
return self.removeDuplicates {
$0[keyPath: keyPath] == $1[keyPath: keyPath]
}
@AppleCEO
AppleCEO / WKUserScript.swift
Last active February 7, 2024 06:36
WKUserScript example
//
// containerView.swift
// WebviewApp
//
// Created by joon-ho kil on 8/28/19.
// Copyright © 2019 길준호. All rights reserved.
//
import UIKit
import WebKit
@atereshkov
atereshkov / xcode-duplicate-line.md
Last active September 5, 2022 07:49
Xcode 13 duplicate line shortcut (hotkey)

Xcode 13 duplicate line shortcut

  1. Run
sudo chmod 666 /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources//IDETextKeyBindingSet.plist
sudo chmod 777 /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources/
struct DependencyInjector {
private static var dependencyList: [String:Any] = [:]
static func resolve<T>() -> T {
guard let t = dependencyList[String(describing: T.self)] as? T else {
fatalError("No povider registered for type \(T.self)")
}
return t
}
@DarkionAvey
DarkionAvey / ios_spinner_avd.xml
Last active April 28, 2023 12:26
iOS-like spinner as an animated vector drawable for Android without the need of custom classes, or worse, gifs. Use support library to get it to work on older devices. To change color, simply change fillColor but not the alpha. You have to register a callback to make it repeat, because android doesn't allow animationset to repeat
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt">
<aapt:attr name="android:drawable">
<vector
android:name="vector"
android:width="20dp"
android:height="20dp"
android:viewportWidth="60"
android:viewportHeight="60">
<path
@MachFour
MachFour / ActionMenu.kt
Last active April 5, 2025 10:46
Jetpack Compose Material3 ActionMenu
import androidx.annotation.StringRes
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Call
import androidx.compose.material.icons.filled.Delete
import androidx.compose.material.icons.filled.Email
import androidx.compose.material.icons.filled.Menu
import androidx.compose.material.icons.filled.MoreVert
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.DropdownMenuItem