Skip to content

Instantly share code, notes, and snippets.

@gnumilanix
gnumilanix / CustomSemantics.kt
Created March 26, 2023 12:52
Compose custom semantics with multiple matchers
import androidx.compose.ui.semantics.SemanticsPropertyKey
import androidx.compose.ui.semantics.SemanticsPropertyReceiver
val DrawableId = SemanticsPropertyKey<List<Int>>(
name = "DrawableResId",
mergePolicy = mergeSemantics()
)
var SemanticsPropertyReceiver.drawableId: Int
get() = throwSemanticsGetNotSupported()
@gnumilanix
gnumilanix / README.md
Last active February 23, 2023 03:32
Service discovery with AWS Cloud Map

This gist provides a sample terraform configuration to use service discovery for ecs service. It is useful when configuring a service that is only accessible internally without having to configure ELB and Route 53.

  1. Create service discovery namespace
  2. Create service discovery configuration A for service B
  3. Create ECS service B to resiger with discovery configuration A
  4. Access service B using dns name

This will automatically register new ECS tasks with Cloud Map when scaling in/out

@gnumilanix
gnumilanix / README.md
Last active February 23, 2023 03:17
Mounting EFS volume to ECS task (EC2) with Terraform

This gist provides a sample terraform configuration to use EFS volume in ECS task running on EC2:

  1. Create a security group A for service B
  2. Create a security group for EFS to allow B
  3. Create EFS file system C and mount target on multiple subnets
  4. Create ECS task D with EFS volume C
  5. Create ECS service for ECS task C with security group A
@gnumilanix
gnumilanix / 2c2p hash.kt
Created August 27, 2020 01:31
Hash function for 2c2p
fun generateHash(data: String, key: String, algorithm: String): String {
val secretKeySpec = SecretKeySpec(key.toByteArray(), algorithm.type)
val mac = Mac.getInstance(algorithm)
mac.init(secretKeySpec)
return Hex.encodeHexString(mac.doFinal(data.toByteArray()))
}

Software Engineer Challenge (Backend)

Introduction

In LalaFood, we are receiving order of delivery day and night. As a software engineer in LalaFood, you have to provide a reliable backend system to clients. Your task here is to implement three endpoints to list/place/take orders.

Requirement

  1. We value a clean, simple working solution.
  2. The application must be run in Docker, candidate must provide docker-compose.yml, which should setup all relevant services/applications.
@gnumilanix
gnumilanix / StepperView.java
Created August 20, 2017 02:29
View that allows incrementing or decrementing values
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.util.AttributeSet;
import android.view.ViewGroup;
import android.widget.ImageView;
@gnumilanix
gnumilanix / ProgressLayout.java
Last active August 20, 2017 02:28
Implementation of FrameLayout that can show progress with in the entire layout
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.animation.TypeEvaluator;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RectF;
public class CheckableImageView extends AppCompatImageView implements Checkable {
private boolean isChecked;
private OnUpdateImageListener onUpdateImageListener;
public CheckableImageView(Context context) {
super(context, null);
}
public CheckableImageView(Context context, AttributeSet attrs) {
super(context, attrs, 0);
@gnumilanix
gnumilanix / ProgressChromeClient.java
Last active June 2, 2017 01:52
Implementation of WebViewClient that can be used to monitor/show/hide progress
import android.annotation.TargetApi;
import android.graphics.Bitmap;
import android.webkit.WebResourceError;
import android.webkit.WebResourceRequest;
import android.webkit.WebView;
import android.webkit.WebViewClient;
/**
* Extension of {@link WebViewClient} that can update caller about changes in the loading progress
*
@gnumilanix
gnumilanix / CircleLayout.java
Last active May 15, 2017 08:27
Implementation of FrameLayout that can wrap any components within with a circle bezel.
package com.milanix.view;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.os.Build;
import android.support.annotation.RequiresApi;
import android.util.AttributeSet;