Skip to content

Instantly share code, notes, and snippets.

View mjm918's full-sized avatar
🍻
Code & Chill

Mohammad Julfikar mjm918

🍻
Code & Chill
View GitHub Profile
@mjm918
mjm918 / PDFGenManager.java
Created July 4, 2022 07:47
Oppo/Vivo Android WebView font bug fixed react-native-html-to-pdf
public class PDFGenManager extends ReactContextBaseJavaModule {
private static final String TAG = "PDFGenManager";
private ReactApplicationContext context;
private File directory;
private String dirPath;
private PDFConverter convertor;
public PDFGenManager(@NonNull ReactApplicationContext reactContext) {
super(reactContext);
this.context = reactContext;
@mjm918
mjm918 / Android-ImageColorsModule.java
Created July 4, 2022 07:40
React-Native Image Swatches / Color
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.util.Base64;
import androidx.annotation.NonNull;
import androidx.palette.graphics.Palette;
import com.bumptech.glide.Glide;
@mjm918
mjm918 / CreateImage.java
Created September 11, 2019 02:37
React Native Android watermark
public class CreateImage extends ReactContextBaseJavaModule {
private String finalPath = "";
private ReactApplicationContext reactApplicationContext = null;
public CreateImage(ReactApplicationContext reactContext) {
super(reactContext);
this.reactApplicationContext = reactContext;
}
@mjm918
mjm918 / CreateImage.h
Created September 11, 2019 02:35
React Native iOS Watermark
//
// CreateImage.h
// Created by Mohammad Julfikar on 28/06/2019.
// Copyright © 2019 Facebook. All rights reserved.
//
#import "RCTBridgeModule.h"
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@mjm918
mjm918 / Banner.h
Last active September 11, 2019 13:19
React Native Banner View (Android & iOS native module)
//
// Banner.h
//
// Created by Mohammad Julfikar on 08/09/2019.
// Copyright © 2019 Facebook. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@mjm918
mjm918 / SpeedTest.js
Created July 16, 2019 12:36
React native check internet speed
export const fetchParallel = (link,header, callback) =>{
const POOR = 150;
const MODERATE = 550;
const GOOD = 2000;
const _start = new Date().getTime();
const speedTester = RNFetchBlob
.config({
@mjm918
mjm918 / ServerReachable.js
Last active March 11, 2024 02:19
React Native check if server is reachable. Sometimes the device shows that you are connected to internet but when you make a request to your server, you dont get any response. This handy code will ping a server and wait for response, if no response, it will alert the user. You can use this code on top of your fetch function. It will run in paral…
export const isReachable = async () =>{
const timeout = new Promise((resolve, reject) => {
setTimeout(reject, 5000, 'Request timed out');
});
const request = fetch('https://xxxxxx.com');
try {
const response = await Promise
.race([timeout, request]);
return true;
}
@mjm918
mjm918 / DownloadManager.h
Created May 22, 2019 05:01
Handy solution to *joltup/rn-fetch-blob* iOS parallel download broken problem
//
// DownloadManager.h
//
// Created by Mohammad Julfikar on 22/05/2019.
// Copyright © 2019 Facebook. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "RCTBridgeModule.h"
@mjm918
mjm918 / sync.js
Created March 1, 2019 03:56
Xilnex sync
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
console.log(JSON.stringify(this.responseText));
}
};
xhttp.open("GET", "LINK_TO_EASYTECH_API?auth=TOKEN", true);
xhttp.send();
@mjm918
mjm918 / XMLHttpRequest.js
Last active March 1, 2019 03:47
Vimigo Code Samples
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
console.log(JSON.stringify(this.responseText));
}
};
xhttp.open("GET", "LINK_TO_EASYTECH_API?date_from=2019-01-10&date_to=2019-02-22&auth=TOKEN", true);
xhttp.send();