Skip to content

Instantly share code, notes, and snippets.

View delacrixmorgan's full-sized avatar
💭
🙉🙈🙊

Morgan Koh delacrixmorgan

💭
🙉🙈🙊
View GitHub Profile
@delacrixmorgan
delacrixmorgan / ArcShortcut.md
Last active October 4, 2023 06:58
Arc Shortcut

Move Address Bar between Sidebar and Webpage

CMD + Shift + D

Paste as New Tab

CMD + Option + V
@delacrixmorgan
delacrixmorgan / SecurityDtoToModelMapper.md
Last active June 7, 2023 13:18
SecurityDtoToModelMapper Question
class SecurityDtoToModelMapper @Inject constructor(
    private val securityDataProvider: SecurityDataProvider,
    private val securityAssetClassDtoToModelMapper: SecurityAssetClassDtoToModelMapper,
    private val securityDividendPolicyDtoToModelMapper: SecurityDividendPolicyDtoToModelMapper,
    private val securityEsgRatingDtoToModelMapper: SecurityEsgRatingDtoToModelMapper,
    private val securityTopHoldingDtoToModelMapper: SecurityTopHoldingDtoToModelMapper,
    private val securityPerformancePointDtoToModelMapper: SecurityPerformancePointDtoToModelMapper,
    private val securityTagsDtoToModelMapper: SecurityTagsDtoToModelMapper,
    private val currencyDtoToModelMapper: CurrencyDtoToModelMapper,
@delacrixmorgan
delacrixmorgan / DrawableMarginSpan.kt
Last active January 6, 2023 14:33
Android SpanUtils - LeadingMarginSpan with Images
internal class DrawableMarginSpan : LeadingMarginSpan {
private val bitmap: Bitmap
private val verticalAlignment: Int
private val padding: Int
private val totalHeight = 0
constructor(bitmap: Bitmap, pad: Int, verticalAlignment: Int) {
this.bitmap = bitmap
padding = pad
this.verticalAlignment = verticalAlignment
@delacrixmorgan
delacrixmorgan / SpanUtils.java
Created January 5, 2023 15:21
Android SpanUtils
package com.csjbot.mobileshop.util;
import android.annotation.SuppressLint;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BlurMaskFilter;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
@delacrixmorgan
delacrixmorgan / DrawOutlineLine.kt
Created December 30, 2022 10:26
Compose UI - Outline Button with Lines
val lineThickness = 4F
Modifier
.fillMaxWidth()
.border(
width = lineThickness.dp,
color = Color.Red,
shape = drawOutlineButtonLine(OutlineButtonLine.Top, lineThickness)
)
private fun drawOutlineButtonLine(outlineButtonLine: OutlineButtonLine, lineThickness: Float): Shape {
@delacrixmorgan
delacrixmorgan / Button.kt
Last active December 30, 2022 09:17
Compose UI - Button
package com.peaks.uicomponents.compose
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsPressedAsState
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
@delacrixmorgan
delacrixmorgan / NoRippleTheme.md
Created December 29, 2022 11:08
Compose UI - No Ripple Theme

By default, Android has ripple effect for all clickable objects. If you want to disable the ripple effect, you will need to wrap it in a LocalRippleTheme.

private object NoRippleTheme : RippleTheme {
    @Composable
    override fun defaultColor() = Color.Unspecified

    @Composable
    override fun rippleAlpha(): RippleAlpha = RippleAlpha(0.0f, 0.0f, 0.0f, 0.0f)
}

Git Cheatsheet

Fetch from Remote and Delete local branches that doesn't exist in Remote.

alias gt='git fetch -p && git branch -vv | grep "origin/.*: gone]" | awk "{print \\\$1}" | xargs git branch -D'

Flutter Cheatsheet

Create Module

flutter create --template=package module_name
@delacrixmorgan
delacrixmorgan / LocalDateTimeTest.kt
Created February 6, 2022 11:13
Get Days To Unit Test - Lost in Java Time with Android
@Test
fun `Given date and date after 30 days When comparing days apart using getDaysTo Then should return 30 days`() {
val startDate = "2020-01-01T12:34:56Z".toLocalDateTime()
val endDate = "2020-01-31T12:34:56Z".toLocalDateTime()
val expectedDifferenceInDays = 30
val differenceInDays = startDate?.getDaysTo(endDate)?.toInt()
Assert.assertEquals(
"Should be $expectedDifferenceInDays",