Skip to content

Instantly share code, notes, and snippets.

View MkhytarMkhoian's full-sized avatar
🏠
Working from home

Mkhytar Mkhoian MkhytarMkhoian

🏠
Working from home
View GitHub Profile
@gpeal
gpeal / fadeTo.kt
Last active October 2, 2024 04:10
Fade To
/**
* Fade a view to visible or gone. This function is idempotent - it can be called over and over again with the same
* value without affecting an in-progress animation.
*/
fun View.fadeTo(visible: Boolean, duration: Long = 500, startDelay: Long = 0, toAlpha: Float = 1f) {
// Make this idempotent.
val tagKey = "fadeTo".hashCode()
if (visible == isVisible && animation == null && getTag(tagKey) == null) return
if (getTag(tagKey) == visible) return
@patrickfav
patrickfav / AesGcmTest.java
Last active February 27, 2024 11:32
Java Authenticated Encryption with AES and GCM.
package at.favre.lib.bytes.otherPackage;
import org.junit.Test;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.spec.GCMParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
@smkhalsa
smkhalsa / fade_on_scroll.dart
Last active January 8, 2025 09:27
A Widget that automatically fades its child based on scroll position
import 'package:flutter/material.dart';
class FadeOnScroll extends StatefulWidget {
final ScrollController scrollController;
final double zeroOpacityOffset;
final double fullOpacityOffset;
final Widget child;
FadeOnScroll(
{Key key,
@RBusarow
RBusarow / TestCoroutineExtension.kt
Last active July 11, 2025 13:30
A JUnit 4 Rule and JUnit 5 Extension for utilizing TestCoroutineDispatcher and TestCoroutineScope from kotlinx.coroutines-test
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.test.TestCoroutineDispatcher
import kotlinx.coroutines.test.TestCoroutineScope
import kotlinx.coroutines.test.resetMain
import kotlinx.coroutines.test.setMain
import org.junit.jupiter.api.extension.AfterAllCallback
import org.junit.jupiter.api.extension.AfterEachCallback
import org.junit.jupiter.api.extension.BeforeAllCallback
import org.junit.jupiter.api.extension.ExtendWith
import org.junit.jupiter.api.extension.ExtensionContext
@Bringoff
Bringoff / DrawOverPermissionActivationListener.java
Last active February 14, 2019 09:30
Overlay drawing permission is activated on separate screen. But after activation that permission some users can't figure out how to return to the original app. Good approach is to open the app automatically after activation. The problem is we cannot listen to overlay permission changes. So here is workaround.
/**
* Looks like there is no adequate way to listen to this permission change, so do workaround here.
* Normally, we check the permission every 0.5 second. But on Oreo this won't work as Settings.canDrawOverlays still
* returns false after activation but before returning to the app (bug https://issuetracker.google.com/issues/66072795).
* Use OnOpChangedListener on Oreo.
*/
public class DrawOverPermissionActivationListener implements LifecycleObserver {
private AppCompatActivity activity;
private final OverlayManager overlayManager;
private final Class activityToBringToFrontOnDetection;
@gildaswise
gildaswise / sliver_refresh_indicator.dart
Created September 13, 2018 20:08
Apple's and Android's refresh indicator to use with CupertinoSliverRefreshControl
import 'dart:math';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
Widget buildAppleRefreshIndicator(
BuildContext context,
RefreshIndicatorMode refreshState,
double pulledExtent,
double refreshTriggerPullDistance,
@sevar83
sevar83 / ControllerLifecycle.kt
Last active August 30, 2019 13:56
Conductor / Glide lifecycle integration
import com.bumptech.glide.manager.Lifecycle
import com.bumptech.glide.manager.LifecycleListener
import com.bumptech.glide.util.Util
import java.util.*
/**
* A [com.bumptech.glide.manager.Lifecycle] implementation for tracking and notifying
* listeners of [com.bluelinelabs.conductor.Controller] lifecycle events.
*/
class ControllerLifecycle : Lifecycle {
@mindplace
mindplace / git_and_github_instructions.md
Last active September 24, 2025 11:29
Pushing your first project to github

1. Make sure git is tracking your project locally

Do you need a refresher on git? Go through Codecademy's git course.

  1. Using your terminal/command line, get inside the folder where your project files are kept: cd /path/to/my/codebase. → You cannot do this simply by opening the folder normally, you must do this with the command line/terminal.
    → Do you need a refresher on using your command line/terminal? I've compiled my favorite resources here.

  2. Check if git is already initialized: git status

@lopspower
lopspower / README.md
Last active November 16, 2025 00:58
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

All hex value from 100% to 0% alpha: