adb kill-server
adb start-server
adb reboot
adb reboot recovery
<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> |
""" | |
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 |
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 |
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 |
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); |
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(); |
//تشخیص اسکرول کردن در لیست | |
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { | |
@Override | |
public void onScrolled(RecyclerView recyclerView, int dx, int dy) { | |
if (dy > 0) { | |
//Scrolling down | |
} else if (dy < 0) { | |
//Scrolling up | |
} |
public static float dpOrSpToPx(final Context context, final float dpOrSpValue) { | |
return dpOrSpValue * context.getResources().getDisplayMetrics().density; | |
} |
//Sort objects by a value | |
Collections.sort(songList, new Comparator<Song>(){ | |
public int compare(Song a, Song b){ | |
// Here song is a class that has some attrs including title. | |
// We want to sort songs by title | |
return a.getTitle().compareTo(b.getTitle()); | |
} | |
}); |