Skip to content

Instantly share code, notes, and snippets.

View rezaiyan's full-sized avatar
👋

Ali Rezaiyan rezaiyan

👋
View GitHub Profile
#!/bin/bash
#hi
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
for rootFolder in */ ; do
if [ -d $rootFolder"build" ]; then
echo "do you want to delete build folders of \"${rootFolder%?}\" project?"
read ans
if [ "$ans" = "y" ] || [ "$ans" = "Y" ]; then
  • Functional Programming is a model of programming that transform and compose stream of immutable sequences by applying map, filter and reduce. Events are immutable because you can't change history.
  • Reactive Programming is a model of programming focuses on data flow and change propagation.
  • ReactiveX is an API that focuses on asynchronous composition and manipulation of observable streams of data or events by using a combination of the Observer pattern, Iterator pattern, and features of Functional Programming.
  • RxJava is the open-source implementation of ReactiveX in Java.
  • RxJava is a Java VM implementation of ReactiveX (Reactive Extensions): a library for composing asynchronous and event-based programs by using observable sequences.
  • RxAndroid is a lightweight extension to RxJava that providers a Scheduler for Android’s Main Thread, as well as the ability to create a Scheduler that runs on any given Android Handler class.
  • The two main classes are Observable and Subscriber.
  • `O
public class PermissionUtil {
/*
* Check if version is marshmallow and above.
* Used in deciding to ask runtime permission
* */
public static boolean shouldAskPermission() {
return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M);
}
private static boolean shouldAskPermission(Context context, String permission){
if (shouldAskPermission()) {
@john990
john990 / SelectImage.java
Created March 27, 2015 06:54
android select image from gallery or camera, and crop
private String cameraFileName;
@Override
public void choiceAvatarFromCamera() {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
cameraFileName = Constants.DOWNLOAD_IMAGE_PATH + System.currentTimeMillis();
File file = new File(Constants.DOWNLOAD_IMAGE_PATH);
if(!file.exists()){
file.mkdirs();
}
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(cameraFileName)));
#!/bin/bash
#hi
echo [UBUNTU PASSWORD] | sudo -S ls
INPUT_NUMBER=$1
SERVER_URL=""
case $INPUT_NUMBER in
1) SERVER_URL="us2.cisadd3.com:800" ;;
2) SERVER_URL="de.cisadd3.com:800" ;;
3) SERVER_URL="uk.cisadd2.com" ;;
4) SERVER_URL="nl.cisadd2.com" ;;
@sockeqwe
sockeqwe / AdapterDelegateDslExample.kt
Created July 22, 2019 08:19
AdapterDelegates Kotlin DSL
/**
* Let's say we want to display a list of Animals in a RecyclerView.
* The list can contain items of type Dog, Cat and Snake.
*/
// AdapterDelegate for Dog.
fun dogAdapterDelegate(picasso : Picasso) = adapterDelegate<Dog, Animal>(R.layout.item_dog){ // Generics Types means this AdapterDelegate is used if item is instanceof Dog (whole list is List<Anmial>)
// this block is run once in onCreateViewHolder. Think of it as an intializer for a ViewHolder.
val name = findViewById(R.id.name)
val image = findViewById(R.id.image)
public class VerticalTimelineDecoration extends RecyclerView.ItemDecoration {
Paint paintFill = null;
Paint paintStrokeFill = null;
Paint paintStroke = null;
Paint paintDotLine = null;
Paint paintText=null;
Paint paintTextBold=null;
@runo280
runo280 / 00readme.md
Last active September 29, 2020 11:36
Download script for C@ster.i0 free courses

How to use

1- Install requirements

This command is for Ubuntu based distros

sudo apt install aria2 youtube-dl

2- Make [course_name].sh file excutable:

chmod +x [course_name].sh

@danylovolokh
danylovolokh / repeatWhen_takeUntil_filter_example.java
Last active February 21, 2021 23:56
Server polling and retry operations when failed. With Retrofit and RxJava.
/**
* This is a class that should be
* mapped on your json response from the server
*/
class ServerPollingResponse {
boolean isJobDone;
@Override
public String toString() {
return "isJobDone=" + isJobDone;
@ysmintor
ysmintor / DownloadActivity.java
Created March 27, 2017 09:23
Android DownloadManager
package com.androidrecipes.downloader;
import android.app.Activity;
import android.app.DownloadManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.database.Cursor;