Skip to content

Instantly share code, notes, and snippets.

View sarkerrabi's full-sized avatar

Md Rabiul Ali Sarker sarkerrabi

View GitHub Profile
#Dagger2 Links
https://github.com/google/dagger
#installers
def dagger_version = 2.29
api "com.google.dagger:dagger:$dagger_version"
annotationProcessor "com.google.dagger:dagger-compiler:$dagger_version"
api "com.google.dagger:dagger-android:$dagger_version"
@sarkerrabi
sarkerrabi / network_security_config.xml
Created June 7, 2020 13:46
network_security_config for android
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>
@sarkerrabi
sarkerrabi / important libs for android
Last active June 3, 2020 09:54
Useful libraries for Android
//bindings
implementation 'com.jakewharton:butterknife:10.2.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1'
//checking internet connection
implementation 'com.novoda:merlin:1.2.0'
//re design logger
implementation 'com.orhanobut:logger:2.2.0'
@sarkerrabi
sarkerrabi / h5_to_tflite_converter.py
Last active July 10, 2023 13:54
To convert an ML(Machine Learning) module like .h5 to tflite
import tensorflow as tf
#store .h5 file in your .py folder
#load h5 module
model=tf.keras.models.load_model('sample_file.h5')
tflite_converter = tf.lite.TFLiteConverter.from_keras_model(model)
#convert
tflite_model = tflite_converter.convert()
open("tf_lite_model.tflite", "wb").write(tflite_model)
@sarkerrabi
sarkerrabi / MakeArrayExtensionsForGrid.swift
Created December 24, 2019 05:50
To make a grid in SwiftUI
import Foundation
extension Array{
func gridData(into size: Int)->[[Element]]{
return stride(from: 0, to: count, by: size).map{
Array(self[$0 ..< Swift.min($0 + size, count)])
}
}
}
@sarkerrabi
sarkerrabi / CommonFileMethod.java
Created December 22, 2019 05:04
Very common need to use for file management issue
public class CommonFileManagement(){
//delete folder in android
public static void deleteFolderWithContent(String dirName){
File dir = new File(Environment.getExternalStorageDirectory().toString() + "/"+dirName);
if (dir.isDirectory())
{
String[] children = dir.list();
for (int i = 0; i < children.length; i++)
{
new File(dir, children[i]).delete();
@sarkerrabi
sarkerrabi / NotificationMaker.java
Created December 12, 2019 09:50
To Make a notification just call it from a method or anywhere
//for greater than android O
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
NotificationChannel channel = new NotificationChannel(CHANNEL_ID,CHANNEL_NAME, NotificationManager.IMPORTANCE_DEFAULT);
channel.setDescription(CHANNEL_DESC);
NotificationManager manager = getSystemService(NotificationManager.class);
manager.createNotificationChannel(channel);
}
// to make notification details
NotificationCompat.Builder builder = new NotificationCompat.Builder(MainActivity.this,CHANNEL_ID)
.setSmallIcon(R.drawable.ic_notifications)