Skip to content

Instantly share code, notes, and snippets.

Avatar
🧐
["curious", "learner", "forward", "patient"];

Mohammad Azimi MohammadAzimi

🧐
["curious", "learner", "forward", "patient"];
View GitHub Profile
View createUrl.js
// curring fuction;
// mix of closure;
function createUrl(baseUrl, protocol = 'https') {
// we can have some other process here
return function (path) {
return `${protocol}://${baseUrl}/${path}`;
}
}
const createClubUrl = createUrl('club.0-1.ir');
@MohammadAzimi
MohammadAzimi / network_security_config.xml
Created May 9, 2021
android network_security_config file for react-native. should be added to android/app/src/main/res/xml
View network_security_config.xml
<!-- react native -->
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">example.net</domain>
<domain includeSubdomains="false">localhost</domain>
<domain includeSubdomains="false">10.0.2.2</domain>
<domain includeSubdomains="false">10.0.3.2</domain>
</domain-config>
<base-config cleartextTrafficPermitted="true">
@MohammadAzimi
MohammadAzimi / .htaccess
Last active Jan 6, 2021
server tricks in react js
View .htaccess
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]
@MohammadAzimi
MohammadAzimi / DeviceDetector.js
Last active Jul 3, 2021
Helper methods and functions - ReactNative, ReactJS, ReactNativeWeb and Monorepo design pattern for single source of code
View DeviceDetector.js
import React from 'react';
import {Image, Platform, StyleSheet, Text, View} from 'react-native';
import {useIsMount} from '/Helper';
const ReactDeviceDetect = Platform.OS === 'web' ? require('react-device-detect') : {}
const {isIOS, isMobile, isMobileOnly, isTablet} = ReactDeviceDetect;
const PORTRAIT = 'portrait-primary';
const initialOrientationValue = Platform.OS === 'web' ? window.matchMedia("(orientation: portrait)").matches : true;