Skip to content

Instantly share code, notes, and snippets.

View galex's full-sized avatar

Alexander Gherschon galex

View GitHub Profile
@galex
galex / DeviceExtensions.kt
Created March 31, 2022 13:56
Extensions for SQLDelight
fun DeviceQueries.saveDevice(device: Device) = insertOrUpdate(
identifier = device.identifier,
appIdentifier = device.appIdentifier,
versionCode = device.versionCode,
versionName = device.versionName,
devicePlatform = device.devicePlatform,
deviceModel = device.deviceModel,
deviceManufacturer = device.deviceManufacturer,
connected = device.connected,
foreground = device.foreground,
package il.co.galex.alexpizzapp.utils
import android.app.Activity
import android.content.Context
import android.content.ContextWrapper
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.ActivityResultRegistry
import androidx.activity.result.contract.ActivityResultContract
import androidx.compose.*
import androidx.ui.core.ContextAmbient
@galex
galex / 1_common.kt
Created April 13, 2019 05:43 — forked from yshrsmz/1_common.kt
Multiplatform ViewModel
expect abstract class ViewModel() {
open fun onCleared()
}
async(UI) {
// before using https://github.com/JakeWharton/retrofit2-kotlin-coroutines-adapter
val call: Call<ApiResponse<List<VideoExtra>>> = service.getVideoExtras(userId)
val response: Response<ApiResponse<List<VideoExtra>>> = bg { call.execute() }.await()
// When using it, our code looks much better
val deferred: Deferred<Response<ApiResponse<List<VideoExtra>>>> = service.getVideoExtras(userId)
val response: Response<ApiResponse<List<VideoExtra>>> = deferred.await()
// using the response's data to set the value of LiveData(), etc...
}
@galex
galex / Preference.kt
Created February 6, 2018 05:30
Shared Preferences as Property Delegates (from the Kotlin for Android Developers book)
package com.talkingkotlin.util
import android.annotation.SuppressLint
import android.content.Context
import android.content.SharedPreferences
import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KProperty
/**
* Shared Preferences as Property Delegates (from the Kotlin for Android Developers book)
@galex
galex / Test.kt
Last active June 23, 2017 15:18
Test to outsmart smart casting
package il.co.kotlintlv.intro
var switch : Boolean = true
class Address(val street: String)
class Person {
val age: Int
val address: Address?
get() {
Verifying that +ghalex is my blockchain ID. https://onename.com/ghalex
###################################
## CartoDB 2.0 Install [Working] ##
## Tested on Ubuntu 12.04 ##
###################################
# Change password
passwd
adduser [username]
adduser [username] sudo
@galex
galex / gradle.build for storm-gen
Created June 11, 2014 10:53
build.gradle for storm-gen since it's in Maven Central
// Top-level build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.11.+'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.3'
}
@galex
galex / build.gradle
Created November 2, 2013 15:29
storm-gen gradle script
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android-library'