Skip to content

Instantly share code, notes, and snippets.

@kcochibili
kcochibili / BillingHolder.java
Last active November 16, 2022 03:50
Singleton class that fixes the issue with the android-inapp-billing-v3 library. This fix allows you to flawlessly use the BillingProcessor in multiple activities, without encountering this issue: https://github.com/anjlab/android-inapp-billing-v3/issues/503
package com.your.package.name;
import android.app.Activity;
import com.anjlab.android.iab.v3.BillingProcessor;
// This singleton class is designed to fix this issue: https://github.com/anjlab/android-inapp-billing-v3/issues/503
// the solution is based on this suggestion: https://github.com/anjlab/android-inapp-billing-v3/issues/501#issuecomment-962612355
public class BillingHolder {
import SwiftUI
import Combine
public struct ChangeObserver<V: Equatable>: ViewModifier {
public init(newValue: V, action: @escaping (V) -> Void) {
self.newValue = newValue
self.newAction = action
}
private typealias Action = (V) -> Void
struct ExpandableButtonPanel: View {
let primaryItem: ExpandableButtonItem
let secondaryItems: [ExpandableButtonItem]
private let noop: () -> Void = {}
private let size: CGFloat = 70
private var cornerRadius: CGFloat {
get { size / 2 }
}
@michaelevensen
michaelevensen / View+Geometry.swift
Last active November 13, 2023 12:20
A really handy extension to `View` which enables dynamic binding of `GeometryReader` properties like `Size`, `Frame` and `SafeAreaInsets` for a `View`. This is particularly handy when you want to share `GeometryReader` output between other `View`'s. All credit goes to @danielsaidi.
//
// View+Geometry.swift
// SwiftUIKit
//
// Created by Daniel Saidi on 2020-03-26.
// Copyright © 2020 Daniel Saidi. All rights reserved.
//
import SwiftUI
@frankfka
frankfka / iOSCustomSegmentedControlSwiftUI.swift
Created May 17, 2020 16:47
Custom Segmented Picker / Segmented Control in SwiftUI
import SwiftUI
extension View {
func eraseToAnyView() -> AnyView {
AnyView(self)
}
}
struct SizePreferenceKey: PreferenceKey {
typealias Value = CGSize
@KanshuYokoo
KanshuYokoo / SwiftUIToastView.swift
Created April 2, 2020 11:44
SwiftuI ToastView example
import SwiftUI
struct ToastView: View {
@State private var liked: Bool = false
var body: some View {
VStack {
LikeButton(liked: $liked)
}
.toast(isShowing: $liked, text: Text("Hello toast!"))
@pratikbutani
pratikbutani / PathUtils.java
Created September 9, 2019 05:53
Get Path from URI or URI from Path Utils.
public class PathUtils {
/**
* To get URI from Path
*
* @param context context
* @param file file
* @return Uri
*/
public static Uri getUriFromPath(Context context, File file) {
String filePath = file.getAbsolutePath();
@ideoforms
ideoforms / sox-cheat-sheet.sh
Last active November 7, 2024 11:43
sox cheat sheet
################################################################################
# sox cheat sheet
################################################################################
# Example commands for the sox command-line audio processing tool,
# for manipulating or batch processing audio files.
################################################################################
# Daniel Jones <[email protected]>
################################################################################
################################################################################
@steven2358
steven2358 / ffmpeg.md
Last active November 11, 2024 04:45
FFmpeg cheat sheet
@tad-iizuka
tad-iizuka / emojiToImage
Created October 20, 2017 03:14
Emoji convert to UIImage. Swift 4
func emojiToImage(text: String, size: CGFloat) -> UIImage {
let outputImageSize = CGSize.init(width: size, height: size)
let baseSize = text.boundingRect(with: CGSize(width: 2048, height: 2048),
options: .usesLineFragmentOrigin,
attributes: [.font: UIFont.systemFont(ofSize: size / 2)], context: nil).size
let fontSize = outputImageSize.width / max(baseSize.width, baseSize.height) * (outputImageSize.width / 2)
let font = UIFont.systemFont(ofSize: fontSize)
let textSize = text.boundingRect(with: CGSize(width: outputImageSize.width, height: outputImageSize.height),
options: .usesLineFragmentOrigin,