Skip to content

Instantly share code, notes, and snippets.

View pantos27's full-sized avatar
💅
coding makes my nails polish peel

Amir A pantos27

💅
coding makes my nails polish peel
View GitHub Profile
@pantos27
pantos27 / PromiseWrapper.ts
Created April 13, 2024 11:13
A typescript way to use React Suspnse blocks with simple promises
const promiseWrapper = <T> (promise: Promise<T>): () => T => {
let status = "pending";
let result: T;
const s = promise.then(
(value) => {
status = "success";
result = value;
},
(error) => {
@pantos27
pantos27 / ApplicationWatcher.kt
Last active January 2, 2024 19:54
A utility class to keep track if your app is in the foreground or background
package com.pantos27.hamburgersforbreakfast
import android.app.Activity
import android.os.Bundle
/**
* A utility class to keep track if your app is in the foreground or background
* without any special permission or API restrictions
* Note that if your app has any activities that run on a different
* process (through the process attribute in your manifest) this utility might not be persistent
*
@pantos27
pantos27 / shell.bat
Last active December 24, 2023 08:26
get current activity wit ADB
adb shell dumpsys window windows | grep -E 'mCurrentFocus|mFocusedApp|mObscuringWindow'
@pantos27
pantos27 / A-Kotlin-Delegates.md
Created December 1, 2021 14:31 — forked from amir-dropit/A-Kotlin-Delegates.md
Kotlin delegates examples

Some Kotlin delegates examples

  • property delegates and class delegates
@pantos27
pantos27 / deploy.yml
Created August 8, 2021 14:42
Github action to auto deploy to branch QA once a new version tag is created
name: deploy-to-qa
on:
workflow_dispatch:
push:
tags: [ 'v*' ]
jobs:
update_qa:
runs-on: ubuntu-latest
steps:
viewModel.viewState.observe(viewLifecycleOwner) { state ->
state takeIfSuccess {
// Here's the success state
} takeIfError {
// Here's the error state
}
}
@pantos27
pantos27 / ConstraintLayoutWithDisableSupport.kt
Created November 17, 2020 16:24
ConstraintLayout with an option to grey out the entire content (disabled like)
package com.example.grayscaleexperiment
import android.content.Context
import android.graphics.Canvas
import android.graphics.ColorMatrix
import android.graphics.ColorMatrixColorFilter
import android.graphics.Paint
import android.util.AttributeSet
import androidx.constraintlayout.widget.ConstraintLayout
@pantos27
pantos27 / intercom.js
Created September 21, 2020 09:12
Helper methods to use Intercom in a type script project
//https://www.intercom.com/help/en/articles/170-integrate-intercom-in-a-single-page-app
const Intercom = {
init: (appId) => {
console.log("Intercom", "init", appId);
const w = window;
const ic = w.Intercom;
w.intercomSettings = {
horizontal_padding: 24,
vertical_padding: 24,
package com.pantos27.gist
import android.os.Bundle
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.FragmentManager
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.Window
import android.widget.FrameLayout
@pantos27
pantos27 / KotlinView.kt
Created July 9, 2019 19:26
Android custom view in Kotlin with all the constructor overloads
package com.pantos27.gist
class KotlinView @JvmOverloads constructor(
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
) : View(context, attrs, defStyleAttr){
init{
//init stuff
}
}