View rotatedRectWithMaxArea.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Given width and height of a rectangle which is rotated from center by angle in radians, | |
//returns width and height of rectangle to crop from center of original image to eliminate the black borders | |
// https://i.stack.imgur.com/KWoeo.jpg | |
//Similar to this image above,input params are input's width and height,rotation in radians | |
//Output is pair.first = width of cropped image in B, pair.second = height of cropped image in B | |
//You can use the scaleCenterCrop function to crop the image bitmap on android | |
// Usage: | |
// Pair<Integer, Integer> pair = rotatedRectWithMaxArea(originalImageWidth, originalImageHeight, Math.toRadians(rotation)); |
View gist:69558fcc182eb5d3a0f44cae47f7194e
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
How to fix errors while uploading themes on wordpress site (Ubuntu NGINX LEMP) | |
[Useful nano shortcut] | |
Search: CTRL + W | |
Save file: CTRL + X | |
1.Fix "413 Request Entity Too Large" Error | |
sudo nano /etc/nginx/nginx.conf | |
Add a line in the http section: |
View hibernateubuntu20.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Enabling Hibernate | |
[https://kaigo.medium.com/ubuntu-20-04-on-dell-xps-15-9570-14efd881f0d2] | |
Install gparted from Ubuntu Software Centre | |
Find the partition with the file system linux-swap | |
Right click > Swapon (if not already on) | |
Right click > Information | |
Copy the UUID=14cee2ec-9d37–4ac0-b594-eae0e55814aa (for example) | |
Add this UUID to /etc/default/grub file by running sudo gedit /etc/default/grub and editing the line |
View gist:bb64ad9ed8a9f5588921aeb77516ed58
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private MovieService() { | |
Retrofit retrofit = new Retrofit.Builder() | |
.baseUrl(URL) | |
.client(new OkHttpClient.Builder().addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY)).build()) | |
.addConverterFactory(GsonConverterFactory.create()) | |
.build(); | |
mMovieApi = retrofit.create(MovieApi.class); | |
} |
View Android formatted string resource
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- <string name="welcome_messages">Hello, %1$s! You have %2$d new messages.</string>--> | |
<!-- String text = res.getString(R.string.welcome_messages, username, mailCount);--> | |
<!-- <plurals name="welcome_messages">--> | |
<!-- <item quantity="one">Hello, %1$s! You have a new message.</item>--> | |
<!-- <item quantity="other">Hello, %1$s! You have %2$d new messages.</item>--> | |
<!-- </plurals>--> | |
<!-- String text = getResources().getQuantityString(R.plurals.welcome_messages, mailCount, username, mailCount);--> | |
<!-- %[parameter_index$][format_type]--> |
View ImagesToPdf.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Just pass context and list of file | |
// It will create a PDF file in cache dir | |
// Add your own logic to share/open PDF | |
// Works fast and reliable method | |
// > - No library needed (Uses android internal android.graphics.pdf.PdfDocument classes) | |
// > - Works in background, Doesn''t freeze UI | |
// > - No need to declare and grant storage permission :) | |
View BaseActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BaseActivity extends FragmentActivity { | |
@Override | |
protected void onCreate(@Nullable Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
IronSource.init(this, AppConfig.IRONSOURCE_APP_KEY); | |
... | |
} | |
} |
View SimpleFlowImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface MFlow<T>{ | |
fun collect(collector: MCollector<T>) | |
} | |
interface MCollector<T>{ | |
fun onEmit(item :T) | |
} | |
// fun mFlowOf(value: String):MFlow<String>{ |
View KotlinContraVarienceAndCovarience
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-----FRUIT BASKET-------- | |
-----MANGO BASKET-------- PUT ANY MEMBER TO FRUIT BASKET AS MANGO - OK, GET ANY MEMBER FROM FRUIT AS MANGO - NOT OK | |
-----MANGO BASKET-------- PUT ANY MEMBER TO KESHAR-MANGO BASKET AS MANGO - NOT OK, GET ANY MEMBER FROM KESHAR-MANGO AS MANGO - OK | |
-----KESHAR-MANGO BASKET-------- | |
View ModularInheritance.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import kotlinx.coroutines.* | |
fun main() { | |
BaseAPIImpl().endpoint1() | |
ModuleAPIImpl().endpoint1() | |
ModuleAPIImpl().endpoint2() | |
(ModuleAPIImpl() as ModuleAPI).endpoint1() | |
(ModuleAPIImpl() as ModuleAPI).endpoint2() | |
} |
OlderNewer