Skip to content

Instantly share code, notes, and snippets.

View omkar-tenkale's full-sized avatar
☸️
Planning

Omkar Tenkale omkar-tenkale

☸️
Planning
View GitHub Profile
//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
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
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
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);
}
@omkar-tenkale
omkar-tenkale / AndroidManifest.xml
Last active November 20, 2022 23:33
android FileUriExposedException fix view file intent crash with fileprovider approach
<provider
android:name=".GenericFileProvider"
android:authorities="${applicationId}"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
<!-- <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 / KeyEvents.java
Created May 29, 2021 08:40
Android KeyEvent with codes in arraylist
public static ArrayList<ArrayList<String>> getKeyEvents() {
return new ArrayList<ArrayList<String>>() {
{
add(new ArrayList<String>() {{
add("UNKNOWN");
add("0");
}});
add(new ArrayList<String>() {{
add("SOFT_LEFT");
@omkar-tenkale
omkar-tenkale / ImagesToPdf.java
Last active July 23, 2021 21:22
Images to pdf android 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 :)
public class BaseActivity extends FragmentActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
IronSource.init(this, AppConfig.IRONSOURCE_APP_KEY);
...
}
}
interface MFlow<T>{
fun collect(collector: MCollector<T>)
}
interface MCollector<T>{
fun onEmit(item :T)
}
// fun mFlowOf(value: String):MFlow<String>{