Skip to content

Instantly share code, notes, and snippets.

View figonzal1's full-sized avatar

Felipe González Alarcón figonzal1

View GitHub Profile
@figonzal1
figonzal1 / .gitignore
Created July 29, 2024 00:40
Android gitignore template
# Built application files
*.apk
*.aar
*.ap_
*.aab
# Files for the ART/Dalvik VM
*.dex
# Java class files
*.class
# Generated files
@figonzal1
figonzal1 / OpenCVCameraFragment.java
Created April 16, 2024 14:28
OpenCV Camera Running in Fragment
package cl.tempus.testopencvjava.ui.main;
import static androidx.core.content.ContextCompat.getSystemService;
import static org.opencv.android.CameraBridgeViewBase.CvCameraViewFrame;
import static org.opencv.android.CameraBridgeViewBase.CvCameraViewListener2;
import static cl.tempus.testopencvjava.utils.MyUtils.detectObjects;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
@figonzal1
figonzal1 / spring-boot-dockerfile-stages
Created September 10, 2022 19:59
Multi stage docker file with multi-layer spring boot and automatic gradle build (3 Stages - build, extract and boot)
# GRADLE BUILD - DOCKER STAGE
FROM gradle:7.5.1-jdk17-alpine as builder
ENV APP_HOME=/app
WORKDIR $APP_HOME
COPY build.gradle settings.gradle $APP_HOME
COPY gradle $APP_HOME/gradle
COPY --chown=gradle:gradle . /home/gradle/src
USER root
RUN chown -R gradle /home/gradle/src
val menuHost: MenuHost = requireActivity()
menuHost.addMenuProvider(object : MenuProvider {
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
menuInflater.inflate(R.menu.myMenu, menu)
}
override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
when (menuItem.itemId) {
R.id.myItem -> {}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
// Handle item click
return when (item.itemId) {
R.id.myItem -> {
true
}
else -> super.onOptionsItemSelected(item)
}
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
val inflater: MenuInflater = menuInflater
inflater.inflate(R.menu.mymenu, menu)
return true
}
val prop = Properties().apply {
load(FileInputStream(File(rootProject.rootDir, "keystore.properties")))
}
signingConfigs {
create("mysign") {
storeFile = file(prop.getProperty("storeFile"))
storePassword = prop.getProperty("storePassword").toString()
keyPassword = prop.getProperty("keyPassword").toString()
keyAlias = prop.getProperty("keyAlias").toString()
//CARGAR VARIABLES DESDE local.properties
with(gradleLocalProperties(rootDir)) {
buildConfigField("String", "MY_VAR", getProperty("MY_VAR"))
}
//EXCLUIR libreria desde una dependencia, ejemplo:
androidTestImplementation("androidx.test.espresso:espresso-contrib:3.4.0") {
exclude("protobuf-lite")
}
include(":app")
rootProject.name = "Kotlin DSL"
//VERSION GROOVY
task clean(type: Delete) {
delete rootProject.buildDir
}
//VERSION DSL
tasks.register("clean", Delete::class) {
delete(rootProject.buildDir)
}