Skip to content

Instantly share code, notes, and snippets.

View mahdi-malv's full-sized avatar

Mahdi Malvandi mahdi-malv

  • Framna (Formerly Shape)
  • Copenhagen, Denmark
  • 14:57 (UTC +02:00)
View GitHub Profile
@mahdi-malv
mahdi-malv / Screenshot.java
Created November 10, 2018 08:25
Take screenshot from screen and save it.
public static void takeScreenshot(Activity activity) {
Date now = new Date();
android.text.format.DateFormat.format("yyyy-MM-dd_hh:mm:ss", now);
try {
// image naming and path to include sd card appending name you choose for file
String mPath = Environment.getExternalStorageDirectory().toString() + "/Screenshot_" + now + ".jpg";
// create bitmap screen capture
View v1 = activity.getWindow().getDecorView().getRootView();
@mahdi-malv
mahdi-malv / CustomToast.java
Created November 10, 2018 08:27
Custom Toast
public static void toast(Context context) {
Toast toast = Toast.makeText(context, "This is a Toast.", Toast.LENGTH_SHORT);
View toastView = toast.getView();
TextView toastMessage = (TextView) toastView.findViewById(android.R.id.message);
toastMessage.setTextSize(19);
toastMessage.setTextColor(Color.BLACK);
toastMessage.setGravity(Gravity.CENTER);
toastMessage.setCompoundDrawablesWithIntrinsicBounds(R.drawable.icon_small, 0, 0, 0);// Add an icon to textView
toastMessage.setCompoundDrawablePadding(16); // Add padding to icon
toastView.setBackgroundColor(Color.WHITE);
@mahdi-malv
mahdi-malv / AdbCommands.md
Created July 1, 2019 09:06 — forked from Pulimet/AdbCommands
Adb useful commands list

Adb Server

adb kill-server
adb start-server 

Adb Reboot

adb reboot
adb reboot recovery 
@mahdi-malv
mahdi-malv / maven_search.sh
Created September 30, 2019 07:08
Get maven repo details using cUrl
curl https://api.bintray.com/search/packages/maven\?g\=co.pushe.plus | python3 -mjson.tool | grep -i name
# Bintray REST: https://bintray.com/docs/api
# ?g is group
# python3 -mjson.tool will beautify the output json
# grep name will get only module names
@mahdi-malv
mahdi-malv / cancelJob.java
Created December 28, 2019 13:36
cancelAndroidJob
public static void cancelJob(Context c, int jobId) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
JobScheduler jobScheduler =
(JobScheduler) c.getSystemService(Context.JOB_SCHEDULER_SERVICE);
jobScheduler.cancel(jobId);
}
}
// Call it like this
@mahdi-malv
mahdi-malv / caster.py
Last active June 20, 2020 06:17
Download a course from caster.io using scrapy and youtube-dl
"""
Prerequisites:
1. Scrapy: python3 -m pip install scrapy
2. Youtube-dl: python3 -m pip install youtube-dl
(Use conda or miniconda for windows to install scrapy. Or use WSL and install python3 on it)
It's also possible to modify this to get other courses from caster.io or even other sites.
"""
from scrapy.spiders import Spider
from scrapy.crawler import CrawlerProcess
import youtube_dl
@mahdi-malv
mahdi-malv / pushe_web_snippet.html
Created September 10, 2020 12:15
Web push snippet to add pushe to your website
<script src="https://static.pushe.co/pusheweb.js"></script>
<script>
Pushe.init("app_id"); // App_id is retrieved via console.pushe.co
Pushe.subscribe({"showDialog":true,"showBell":false,"icon":"https://static.pushe.co/d/webpush/default-icon.png","title":"Get the latest news bro :D","content":"You want to be notified of every new event happenning to My site? Click OK then.","position":"top-center","direction":"ltr","acceptText":"OK, sure","rejectText":"Nuh","promptTheme":"pushe-prompt-theme2","mobilePosition":"top","dialogRetryRate":0});
</script>
@mahdi-malv
mahdi-malv / flutter_pushe_web_index.html
Created September 10, 2020 12:22
Flutter web with pushe applied
<body>
<!-- region Add pushe before your Flutter script -->
<script src="https://static.pushe.co/pusheweb.js"></script>
<script>
Pushe.init("app_id"); // App_id is retrieved via console.pushe.co
Pushe.subscribe({"showDialog":true,"showBell":false,"icon":"https://static.pushe.co/d/webpush/default-icon.png","title":"Get the latest news bro :D","content":"You want to be notified of every new event happenning to My site? Click OK then.","position":"top-center","direction":"ltr","acceptText":"OK, sure","rejectText":"Nuh","promptTheme":"pushe-prompt-theme2","mobilePosition":"top","dialogRetryRate":0});
</script>
<!-- endregion-->
<!-- region Flutter's own code -->
@mahdi-malv
mahdi-malv / logs-17-09-2020.txt
Created September 17, 2020 10:13
DUMP: Huawei push log (Tag: pushlog and Tag: HMS) - Galaxy A40 - From 0 to sending uplink message
// TAG: pushlog
2020-09-17 13:54:34.677 10602-10602/? I/SEMS:DataAdapterLog_11.1.0: [SEMS][PushLog][2][SmpManager] Instance created
2020-09-17 13:54:34.677 10602-10602/? I/SEMS:DataAdapterLog_11.1.0: [SEMS][PushLog][2][SmpManager] registerMessageCallback - 0
2020-09-17 13:54:34.677 10602-10602/? I/SEMS:DataAdapterLog_11.1.0: [SEMS][PushLog][2][SmpManager] registerTokenCallback
2020-09-17 13:54:34.837 10602-10602/? I/SEMS:DataAdapterLog_11.1.0: [SEMS][PushLog][2][SmpManager] registerMessageCallback - 9
2020-09-17 13:54:34.850 10602-10602/? I/SEMS:DataAdapterLog_11.1.0: [SEMS][PushLog][2][SmpManager] registerMessageCallback - 7
2020-09-17 13:54:34.850 10602-10602/? I/SEMS:DataAdapterLog_11.1.0: [SEMS][PushLog][2][SmpManager] registerMessageCallback - 8
2020-09-17 13:54:34.863 10602-10602/? I/SEMS:DataAdapterLog_11.1.0: [SEMS][PushLog][2][SmpManager] registerMessageCallback - 12
2020-09-17 13:54:34.872 10602-10602/? I/SEMS:DataAdapterLog_11.1.0: [SEMS][PushLog][2][SmpManager] registerMessageCallback - 13
@mahdi-malv
mahdi-malv / hms_log.txt
Last active September 19, 2020 13:19
HSM core with phone permission log - Samsung Galaxy-A40
//// pushlog
2020-09-19 17:47:36.806 24125-24569/? I/PushLog50002300_HMS: [I/PushKit/PushLog50002300_HMS 24125:7415 null:81] MainEntry register success
2020-09-19 17:47:36.836 24125-24569/? E/PushLog50002300_HMS: [E/PushKit/PushLog50002300_HMS 24125:7415 null:139] HwCfgFilePolicy ClassNotFoundException
2020-09-19 17:47:36.836 24125-24569/? I/PushLog50002300_HMS: [I/PushKit/PushLog50002300_HMS 24125:7415 null:58] push jarFile is not exist
2020-09-19 17:47:36.839 24125-24569/? I/PushLog50002300_HMS: [I/PushKit/PushLog50002300_HMS 24125:7415 null:64] getEmuiLevel:0
2020-09-19 17:47:37.803 24125-24583/? I/PushLog50002300_HMS: [I/PushKit/PushLog50002300_HMS 24125:7424 null:8] process hms token for EMUI, return
2020-09-19 17:47:37.955 24125-24583/? W/PushLog50002300_HMS: [W/PushKit/PushLog50002300_HMS 24125:7424 null:40] genarate hmstokensign:hmsToken is null.
2020-09-19 17:47:37.979 24125-24678/? I/PushLog50002300_HMS: [I/PushKit/PushLog50002300_HMS 24125:7452 null:41] update xml data, old version is 0,new versi