Skip to content

Instantly share code, notes, and snippets.

@ranbims
ranbims / SlidesImageSizeClassifier.py
Created July 5, 2021 05:42
Divide the images in a folder into two types. Mainly works on 4:3 and 16:9 images.
import os
import imghdr
from pathlib import Path
import shutil
import uuid
from PIL import Image
from shutil import copyfile
def create_folder_if_not_exist(target_path: Path):
if (target_path.exists()):
@ranbims
ranbims / check notification permission
Created September 10, 2020 02:43 — forked from coolya/check notification permission
How to check if you app has permission to get notification service listener
boolean hasNotificationAccess()
{
ContentResolver contentResolver = this.getContentResolver();
String enabledNotificationListeners = Settings.Secure.getString(contentResolver, "enabled_notification_listeners");
String packageName = this.getPackageName();
// check to see if the enabledNotificationListeners String contains our package name
return !(enabledNotificationListeners == null || !enabledNotificationListeners.contains(packageName));
}
@ranbims
ranbims / themes-debug.xml
Created July 6, 2018 10:05 — forked from dlew/themes-debug.xml
With the new theming in AppCompat, a lot of assets are tinted automatically for you via theme attributes. That has often led me to wonder "where the hell did this color come from?" You can replace your normal theme with this debug theme to help figure out the source of that color.
<!-- You can change the parent around to whatever you normally use -->
<style name="DebugColors" parent="Theme.AppCompat">
<!-- System colors -->
<item name="android:windowBackground">@color/__debugWindowBackground</item>
<item name="android:colorPressedHighlight">#FF4400</item>
<item name="android:colorLongPressedHighlight">#FF0044</item>
<item name="android:colorFocusedHighlight">#44FF00</item>
<item name="android:colorActivatedHighlight">#00FF44</item>