Skip to content

Instantly share code, notes, and snippets.

@ciriti
ciriti / AAX2MP3.sh
Last active January 1, 2024 17:15
Script to convert mp3 files to mp4
#!/bin/bash
# Get the authentication code from an environment variable
auth_code="$AUTH_CODE"
# Check if the authentication code is empty
if [ -z "$auth_code" ]; then
echo "Error: Authentication code not set. Please set the AUTH_CODE environment variable."
exit 1
fi
repositories {
jcenter()
}
configurations {
ktlint
}
dependencies {
ktlint "com.pinterest:ktlint:0.36.0"
<?xml version="1.0" encoding="utf-8"?>
<com.example.passiveviewpattern.UserLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp">
<!-- others view components -->
fun UserLayout.bind(data : UserData){
nameTv.text = data.name
ageTv.text = data.age
/** other fields */
}
data class UserData(
val name : String,
val surnaname : String,
val age : String,
var urlImage : String,
val city : String,
val desc : String
)
class UserLayout @JvmOverloads constructor(
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
) : ConstraintLayout(context, attrs, defStyleAttr)
import com.nhaarman.mockito_kotlin.mock
import com.nhaarman.mockito_kotlin.times
import com.nhaarman.mockito_kotlin.verify
import org.junit.Test
class InterfaceSegregationTest {
val mock = mock<()->Unit>()
@Test
class Client(eventTrigger : EventTrigger){
init {
eventTrigger.setEventListener {
onEventType_1 { println("event $it") }
}
}
}
fun EventTrigger.setEventListener(init: EventListenerImpl.() -> Unit) {
val listener = EventListenerImpl()
...
}
class EventTrigger(var eventListener: EventListener? = null) {
fun triggerEventType1() {
eventListener?.onEventType_1("event 1")
}
}