This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Convert from H264 to H265 | |
ffmpeg -i in.mov -c:v libx265 -an -x265-params crf=20 output.mp4 | |
# Tag as HVC instead of HEV1 so iOS can play it | |
ffmpeg -i output.mp4 -vcodec copy -acodec copy -tag:v hvc1 output2.mp4 | |
# Bonus: it can take a second to play (no more than H264) so here's how to generate | |
# a thumbnail of the first frame to embed in your view as a placeholder. | |
ffmpeg -i output2.mp4 -vf "select=eq(n\,34)" -vframes 1 thumbnail.png |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (C) 2020 Raul Hernandez Lopez | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import timber.log.Timber | |
import kotlin.properties.ReadOnlyProperty | |
import kotlin.reflect.KProperty | |
class MyClass { | |
// This will automatically have the TAG "MyClass" | |
private val log by timber() | |
fun logSomething() { | |
log.i("Hello") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Like Delegates.observable except it only calls the callback when the value actually changes. | |
*/ | |
public inline fun <T> uniqueObservable(initialValue: T, emitInitial: Boolean = false, crossinline onChange: (value: T) -> Unit): ReadWriteProperty<Any?, T> { | |
if (emitInitial) onChange(initialValue) | |
return object : ObservableProperty<T>(initialValue) { | |
override fun afterChange(property: KProperty<*>, oldValue: T, newValue: T) { | |
if (oldValue != newValue) onChange(newValue) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Fade a view to visible or gone. This function is idempotent - it can be called over and over again with the same | |
* value without affecting an in-progress animation. | |
*/ | |
fun View.fadeTo(visible: Boolean, duration: Long = 500, startDelay: Long = 0, toAlpha: Float = 1f) { | |
// Make this idempotent. | |
val tagKey = "fadeTo".hashCode() | |
if (visible == isVisible && animation == null && getTag(tagKey) == null) return | |
if (getTag(tagKey) == visible) return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class WifiNetworksFragment : TonalFragment(R.layout.wifi_networks_fragment) { | |
// This automatically creates and clears the binding in a lifecycle-aware way. | |
private val binding: WifiNetworksFragmentBinding by viewBinding() | |
... | |
} | |
class WifiNetworkView @JvmOverloads constructor( | |
context: Context, | |
attrs: AttributeSet? = null, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ContentView.swift | |
// Example of using matchedGeometryEffect in iOS 13 code | |
// matchedGeometryEffect example code taken and adapted from : | |
// https://sarunw.com/posts/a-first-look-at-matchedgeometryeffect/ | |
// | |
// Created by Emil Pedersen on 16/10/2020. | |
// | |
struct ContentView: View { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Deps | |
interface Database | |
interface Network | |
// Child | |
interface ChildRepository | |
class Child(dependencies: Dependencies) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.basebeta.utility.logging.kprint | |
import kotlinx.atomicfu.atomic | |
import kotlinx.coroutines.* | |
import kotlinx.coroutines.channels.BroadcastChannel | |
import kotlinx.coroutines.channels.Channel | |
import kotlinx.coroutines.flow.* | |
class StateWrapper<T>(var state: T) | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// This is a simple example of Neumorphism applied to buttons in SwiftUI | |
/// As seen on https://twitter.com/dev_jac/status/1228575575171723264 | |
/// This should work straight out of the box, no other files are required | |
import SwiftUI | |
extension Color { | |
static let mainColor = Color(red: 224/255, green: 229/255, blue: 236/255) | |
static let mainColorActive = Color(red: 220/255, green: 225/255, blue: 232/255) | |
static let grayShadow = Color(red: 163/255, green: 177/255, blue: 198/255) |
NewerOlder