Skip to content

Instantly share code, notes, and snippets.

Avatar
☸️
Planning

Omkar Tenkale omkar-tenkale

☸️
Planning
  • FRND
  • India
View GitHub Profile
View rotatedRectWithMaxArea.java
//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));
@omkar-tenkale
omkar-tenkale / gist:69558fcc182eb5d3a0f44cae47f7194e
Last active March 12, 2021 07:56
nginx ubuntu wordpress theme upload error
View gist:69558fcc182eb5d3a0f44cae47f7194e
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:
@omkar-tenkale
omkar-tenkale / hibernateubuntu20.txt
Created March 12, 2021 16:22
hibernate ubuntu 20 steps to enable hibernation
View hibernateubuntu20.txt
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
@omkar-tenkale
omkar-tenkale / gist:bb64ad9ed8a9f5588921aeb77516ed58
Created March 12, 2021 17:46
retrofit logging to logcat one line
View gist:bb64ad9ed8a9f5588921aeb77516ed58
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
<!-- <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]-->
@omkar-tenkale
omkar-tenkale / ImagesToPdf.java
Last active July 23, 2021 21:22
Images to pdf android java
View ImagesToPdf.java
// 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
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
interface MFlow<T>{
fun collect(collector: MCollector<T>)
}
interface MCollector<T>{
fun onEmit(item :T)
}
// fun mFlowOf(value: String):MFlow<String>{
View KotlinContraVarienceAndCovarience
-----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--------
@omkar-tenkale
omkar-tenkale / ModularInheritance.kt
Created September 13, 2022 07:56
Inheritance for multi module project in kotlin, android
View ModularInheritance.kt
import kotlinx.coroutines.*
fun main() {
BaseAPIImpl().endpoint1()
ModuleAPIImpl().endpoint1()
ModuleAPIImpl().endpoint2()
(ModuleAPIImpl() as ModuleAPI).endpoint1()
(ModuleAPIImpl() as ModuleAPI).endpoint2()
}