Skip to content

Instantly share code, notes, and snippets.

View Bloody-Badboy's full-sized avatar
😪
Wake me up when we can travel again

Arpan Sarkar Bloody-Badboy

😪
Wake me up when we can travel again
View GitHub Profile
@Bloody-Badboy
Bloody-Badboy / OtpInput.tsx
Created March 12, 2022 15:12
A simple 6 digit OTP input using https://mui.com
import { Box, OutlinedInput } from '@mui/material';
import React, { useRef, useEffect } from 'react';
type Props = {
onChange: (res: string) => void;
};
const OtpInput: React.FC<Props> = ({ onChange }) => {
const inputsRef = useRef<Array<HTMLInputElement>>([]);
@Bloody-Badboy
Bloody-Badboy / JWE.kt
Created January 26, 2022 06:23
JWE RSA_OAEP_256 + A256GCM encryption / decryption
import org.json.JSONObject
import java.net.URLDecoder
import java.net.URLEncoder
import java.security.AlgorithmParameters
import java.security.KeyPair
import java.security.KeyPairGenerator
import java.security.SecureRandom
import java.security.interfaces.RSAPrivateKey
import java.security.interfaces.RSAPublicKey
import java.security.spec.MGF1ParameterSpec
package dev.arpan.motionlayout.playground
import android.view.View
import androidx.core.view.ViewCompat
import androidx.viewpager2.widget.ViewPager2
class StackPageTransformer : ViewPager2.PageTransformer {
override fun transformPage(page: View, position: Float) {
page.apply {
when {
@Bloody-Badboy
Bloody-Badboy / MoshiContentConverter.kt
Last active October 5, 2022 16:41
MoshiContentConverter & MoshiWebSocketContentConverter for Ktor server
import com.squareup.moshi.JsonDataException
import com.squareup.moshi.JsonEncodingException
import com.squareup.moshi.Moshi
import io.ktor.http.ContentType
import io.ktor.http.content.OutgoingContent
import io.ktor.http.content.TextContent
import io.ktor.http.withCharset
import io.ktor.serialization.ContentConverter
import io.ktor.server.plugins.contentnegotiation.ContentNegotiationConfig
@Bloody-Badboy
Bloody-Badboy / IconView.kt
Created August 2, 2021 17:11 — forked from nickbutcher/IconView.kt
A prototype implementation of a shadow effect inspired by the Google Play Games app (https://play.google.com/store/apps/details?id=com.google.android.play.games).
/*
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@Bloody-Badboy
Bloody-Badboy / MSI.md
Created June 17, 2021 19:20
Keymaps MSI Prestige And MSI Modern FnKeys and Special keys

sudo nano /lib/udev/hwdb.d/60-keyboard.hwdb

add at the end of the # Micro-Star section

# Keymaps MSI Prestige And MSI Modern FnKeys and Special keys
evdev:atkbd:dmi:bvn*:bvr*:bd*:svnMicro-Star*:pn*Prestige*:*
evdev:atkbd:dmi:bvn*:bvr*:bd*:svnMicro-Star*:pn*Modern*:*
 KEYBOARD_KEY_56=backslash                              # Secondary backslash key
 KEYBOARD_KEY_f1=f20                                    # Fn+F5 Micmute
@Bloody-Badboy
Bloody-Badboy / ImageCompressor.kt
Last active March 8, 2021 16:45
A utility class load and compress image from Uri
import android.content.Context
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.graphics.Matrix
import android.net.Uri
import android.os.ParcelFileDescriptor
import android.util.Log
import androidx.exifinterface.media.ExifInterface
import java.io.ByteArrayOutputStream
import java.io.FileNotFoundException
@Bloody-Badboy
Bloody-Badboy / ExamplePreferenceStore .kt
Created March 7, 2021 16:37
Android SharedPreferences extentions
import android.content.Context
import android.content.Context.MODE_PRIVATE
import android.content.SharedPreferences
import kotlinx.coroutines.channels.ConflatedBroadcastChannel
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.asFlow
interface ExamplePreferenceStore {
@Bloody-Badboy
Bloody-Badboy / BaseFragment.kt
Created March 2, 2021 07:42
ViewBinding Fragment that destroy binding when view destroyed to prevent memory leaks
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.annotation.LayoutRes
import androidx.databinding.DataBindingUtil
import androidx.fragment.app.Fragment
import androidx.viewbinding.ViewBinding
open class BaseFragment<out Binding : ViewBinding>(@LayoutRes contentLayoutId: Int) :
import android.content.Context
import android.text.Editable
import android.text.InputFilter
import android.text.InputType
import android.text.TextWatcher
import android.util.AttributeSet
import android.widget.EditText
import androidx.appcompat.widget.AppCompatEditText
import java.text.SimpleDateFormat
import java.util.*