Skip to content

Instantly share code, notes, and snippets.

@ziglee
ziglee / TextField.kt
Created February 19, 2024 09:27
Compose clickable readonly textfield
OutlinedTextField(
modifier = Modifier
.pointerInput(Unit) {
awaitEachGesture {
awaitFirstDown(pass = PointerEventPass.Initial)
val upEvent =
waitForUpOrCancellation(pass = PointerEventPass.Initial)
if (upEvent != null) {
onClick()
}
@ziglee
ziglee / DashedDivider.kt
Last active February 21, 2023 14:33
Jetpack Compose DashedDivider
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.PathEffect
@ziglee
ziglee / TestDataStore.kt
Created January 12, 2023 12:07
"multiple instances" error when removing value during unit testing
import android.content.Context
import androidx.datastore.core.DataStore
import androidx.datastore.preferences.core.PreferenceDataStoreFactory
import androidx.datastore.preferences.core.Preferences
import androidx.datastore.preferences.core.edit
import androidx.datastore.preferences.core.stringPreferencesKey
import androidx.datastore.preferences.preferencesDataStoreFile
import androidx.test.core.app.ApplicationProvider
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi
@ziglee
ziglee / config.yml
Last active March 14, 2018 17:13
CircleCI android + sonarqube scanner
version: 2
jobs:
build:
dependencies:
pre:
- echo y | android update sdk --no-ui --all --filter "com.android.tools.build:gradle:3.0.1"
docker:
- image: circleci/android:api-26-alpha
environment:
JVM_OPTS: -Xmx3200m
@ziglee
ziglee / sonarqube-docker-compose.yml
Created March 7, 2018 17:37
Sonarqube + PostgreSQL (Docker Compose)
version: "2"
services:
sonarqube:
image: sonarqube:6.7.1
ports:
- "9000:9000"
networks:
- sonarnet
environment:
@ziglee
ziglee / build.gradle
Created January 12, 2018 13:47
Build gradle excerpt that uses Jenkins BUILD_NUMBER to compose the versionCode in AndroidManifest.xml
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.25.1'
}
}
apply plugin: 'com.android.application'
@ziglee
ziglee / disablebuildcache.groovy
Last active January 12, 2018 12:45
Disable android build chache in gradle properties
File propsFile = new File('./gradle.properties')
if (!propsFile.exists()) {
propsFile.withWriterAppend { w -> w << 'android.enableBuildCache = false' }
} else {
Properties props = new Properties()
props.load(propsFile.newDataInputStream())
props.setProperty('android.enableBuildCache', 'false')
props.store(propsFile.newWriter(), null)
}
package br.com.celg.pd318
class StudsUtil {
static enum SeqPosition {
START,
MIDDLE,
END
}
import android.text.TextUtils;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.net.SocketTimeoutException;
import javax.net.ssl.HttpsURLConnection;
import br.com.experience.hsm.data.entity.ErrorEntity;
@ziglee
ziglee / routes.js
Last active August 21, 2021 15:05
Listing all Costumers with birthday today or tomorrow using Sequelize.js.
router.get('/api/birthday', function (req, res, next) {
var month = moment().month() + 1;
var today = moment().date();
var tomorrow = moment().add(1, 'days').date();
Costumer.findAll({
attributes: ['id','name','birthDate'],
where: {
$and: [
sequelize.where(sequelize.fn('month', sequelize.col("birth_date")), month)
],