Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View akexorcist's full-sized avatar
🔥

Akexorcist akexorcist

🔥
View GitHub Profile
@akexorcist
akexorcist / buddhist-year.js
Last active April 5, 2024 07:47
MomentJS with Buddhist year
module.exports = {
toBuddhistYear: (moment, format) => {
var christianYear = moment.format('YYYY')
var buddhishYear = (parseInt(christianYear) + 543).toString()
return moment
.format(format.replace('YYYY', buddhishYear).replace('YY', buddhishYear.substring(2, 4)))
.replace(christianYear, buddhishYear)
}
}
@akexorcist
akexorcist / AnyWhere.java
Created April 2, 2017 20:30
Singleton Sound Player in Android
SoundPoolManager.getInstance().play(getContext(), R.raw.any_sound);
MediaPlayerManager.getInstance().play(getContext(), R.raw.any_sound);
@akexorcist
akexorcist / device_list.txt
Last active December 12, 2023 11:20
Android Device List in Firebase Test Lab [12 December 2023] from `gcloud firebase test android models list`
┌─────────────────────┬────────────┬──────────────────────────────────────────┬──────────┬─────────────┬────────────────────────────┬──────────────────────┐
│ MODEL_ID │ MAKE │ MODEL_NAME │ FORM │ RESOLUTION │ OS_VERSION_IDS │ TAGS │
├─────────────────────┼────────────┼──────────────────────────────────────────┼──────────┼─────────────┼────────────────────────────┼──────────────────────┤
│ 1610 │ Vivo │ vivo 1610 │ PHYSICAL │ 1280 x 720 │ 23 │ reduced_stability=23 │
│ AmatiTvEmulator │ Google │ Google TV Amati │ VIRTUAL │ 1080 x 1920 │ 29 │ beta=29 │
│ AndroidTablet270dpi │ Generic │ Generic 720x1600 Android tablet @ 270dpi │ VIRTUAL │ 1600 x 720 │ 30 │ │
│ F01L │ FUJITSU │ F-01L │ PH
@akexorcist
akexorcist / app_listing.java
Last active August 29, 2023 02:16
Get application name android package name from all application which have launcher (Not all app in device)
PackageManager pm = getPackageManager();
Intent main = new Intent(Intent.ACTION_MAIN, null);
main.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> packages = pm.queryIntentActivities(main, 0);
ArrayList<String> app_name_list = new ArrayList<String>();
ArrayList<String> app_package_list = new ArrayList<String>();
for(ResolveInfo resolve_info : packages) {
try {
@akexorcist
akexorcist / android.yml
Created April 1, 2021 03:38
Android CI + FIrebase Test Labs
name: Android CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
test:
@akexorcist
akexorcist / move_artifact_from_jfrog_to_nexus.sh
Last active June 30, 2023 10:32
Nexus Artifact Migration for macOS with zsh. In case you need to copy artifact from Nexus to another nexus repository
#!/bin/zsh
# Copy artifact from JFrog to another Nexus
#
# ## Prerequisites: ##
# * macOS
# * zsh
# * jq
# * wget
# * curl
# * JFrog
@akexorcist
akexorcist / prevent_accesssibility.kt
Created February 23, 2023 09:00
Prevent accessibility action in Android views
import android.core.view.AccessibilityDelegateCompat
import android.core.view.ViewCompat
val button: Button = /* ... */
ViewCompat.setAccessibilityDelegate(
button,
object : AccessibilityDelegateCompat() {
override fun performAccessibilityAction(host: View?, action: Int, args: Bundle?): Boolean {
return false
@akexorcist
akexorcist / MainActivity.kt
Created January 6, 2023 11:51
Sample of dialog listener unbinding when device configuration has changed (e.g, dark theme, language, screen orientation)
package com.lmwn.poc.dialogwithconfigchanges
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.DialogFragment
import com.lmwn.poc.dialogwithconfigchanges.databinding.ActivityMainBinding
import com.lmwn.poc.dialogwithconfigchanges.databinding.ViewAwesomeDialogBinding
@akexorcist
akexorcist / index.js
Last active November 17, 2022 11:25
Axios post method requesting with x-www-form-urlencoded content type. See https://axios-http.com/docs/urlencoded
const axios = require('axios')
/* ... */
const params = new URLSearchParams()
params.append('name', 'Akexorcist')
params.append('age', '28')
params.append('position', 'Android Developer')
params.append('description', 'birthdate=25-12-1989&favourite=coding%20coding%20and%20coding&company=Nextzy%20Technologies&website=http://www.akexorcist.com/')
params.append('awesome', true)
@akexorcist
akexorcist / Code.java
Created June 6, 2014 08:19
Get Real Path from URI which choose from intent
// Image Media Path : /document/image:48645
// Real file Path : /storage/emulated/0/DCIM/Camera/IMG_20140606_123326982.jpg
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_GALLERY && resultCode == RESULT_OK) {
Uri uri = data.getData();
String path = getRealPathFromURI(getApplicationContext(), uri);
Log.e("Check", "URI Path : " + uri.getPath());