Skip to content

Instantly share code, notes, and snippets.

View adityahas's full-sized avatar
🍉
Papaya?

Aditya Hastungkoro Hadi adityahas

🍉
Papaya?
View GitHub Profile
@adityahas
adityahas / springboot.md
Created October 16, 2025 17:02
TransientObjectException Hibernate Springboot Error

Question:

aku punya mapper seperti ini: @Mapping(target = "customer.id", source = "customerId")

kenapa ketika datanya null di request body akan error seperti ini: org.hibernate.TransientObjectException: persistent instance references an unsaved transient instance of 'com.opteraone.datastore.db.entity.User' (save the transient instance before flushing)

Answer:

@adityahas
adityahas / gist:003822bc95f0ce321955323a9b2db513
Created October 1, 2025 18:23
Hibernate Filter on Child Table

🚀 Hibernate Tip: Gunakan @Filter untuk Child Collection

Sering ketemu kasus entity tree di Hibernate yang terlalu "berisik"? Misalnya: TaskCategory → TaskFlow → TaskChecklist, tapi kamu cuma mau ambil yang isActive = true di level child.

Daripada filter manual di service/DTO, Hibernate sudah punya fitur bawaan: @Filter.

@FilterDef(name = "activeChecklistFilter", parameters = @ParamDef(name = "activeOnly", type = Boolean.class))
@adityahas
adityahas / gist:bef19012b16112d22314f2fe8e50c906
Last active September 26, 2024 15:33
Flutter Cheat: Adding Separators in List Items

In Jetpack Compose, adding a separator between list items is easy with Arrangement.spacedBy. However, Flutter doesn’t provide a built-in method for this. This tutorial will show you how to create a custom extension in Flutter to achieve a similar effect.

1. Creating a List Extension for Adding Separators

We’ll create an extension on the List class to add a separator widget between each element of the list. This can be used for any list of widgets, such as Column, Row, or ListView.

Step 1: Implement the Extension

The following extension method insertSeparator inserts a separator between each element in the list.

@adityahas
adityahas / BulletPointTextField.kt
Created May 24, 2024 08:53
Compose component for TextField with bullet points
package mba.lumina.design.component.text_field
import android.view.KeyEvent
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
@adityahas
adityahas / measure_size.md
Last active January 24, 2024 04:04
Flutter measure widget size and add widget with condition

Mesure widget size

import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';

class MeasureSize extends StatefulWidget {
  final Widget child;
  final Function(Size size) onChange;

 const MeasureSize({
@adityahas
adityahas / gist:9bf1450a98673fe7a7eb761d319d16d1
Last active January 24, 2024 04:05
Multiple SSH Key with ZSH
# Add bellow lines to your .zshrc
# Make sure this line exists
plugins=(git ssh-agent)
# Enable ssh-agent forwarding
zstyle :omz:plugins:ssh-agent agent-forwarding yes
# Load ssh identities
zstyle :omz:plugins:ssh-agent identities ~/.ssh/{id_ed25519,id_akarinti}
@adityahas
adityahas / mac-must-have-apps.md
Last active December 1, 2023 09:10
Mac OS Must Have Apps/Tools
@adityahas
adityahas / gist:f952cfddd3f507faa609de44f5ca9467
Last active November 16, 2023 07:25
Fix git ssh issue when using more than 1 key
Solving the SSH clone problem:
The SSH clone was giving the same error as the HTTPS clone. Some background on bash agents is helpful here.
I found my ~/.ssh/config file in my user directory and verified the repo had an entry there.
Host [my_gitlab_server]/[repo]
IdentityFile ~/.ssh/id_rsa2
I had multiple id-rsa files in the ssh directory, so I opened id_rsa2.pub (the one associated with my repo in the config file) and compared it to the key I found in my repo by navigating to the 'SSH Keys' tab in my 'Profile Settings'. The keys were the same.
#!/usr/bin/env bash
# inspired by
# https://gist.github.com/JannikArndt/feb720c1f5d210b4820b880af23f2a07
# which was inspired by
# https://github.com/fwartner/mac-cleanup/blob/master/cleanup.sh
# https://gist.github.com/jamesrampton/4503412
# https://github.com/mengfeng/clean-my-mac/blob/master/clean_my_mac.sh
# https://github.com/szymonkaliski/Dotfiles/blob/master/Scripts/clean-my-mac
# http://brettterpstra.com/2015/10/27/vacuuming-mail-dot-app-on-el-capitan/ / https://github.com/pbihq/tools/blob/master/MailDBOptimiser.sh
@adityahas
adityahas / jht_payment_details_page.dart
Last active August 25, 2023 00:39
This is how to listen from bloc to ui in Flutter Bloc
class JhtPaymentDetailsPage extends StatelessWidget {
const JhtPaymentDetailsPage({super.key, required this.cardId});
final String cardId;
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) =>
JhtPaymentDetailCubit(di(), di(), di())..init(cardId),