Skip to content

Instantly share code, notes, and snippets.

View MohammadAzimi's full-sized avatar
🧐
["curious", "learner", "forward", "patient"];

Mohammad Azimi MohammadAzimi

🧐
["curious", "learner", "forward", "patient"];
View GitHub Profile
@MohammadAzimi
MohammadAzimi / build.gradle
Created March 12, 2023 06:40
Disable sentry source map upload (Android)
// avoid uploading sourcemap: add these line at the end of:
// app/build.gradle
gradle.projectsEvaluated {
def tasksToSkip = project.tasks.matching {
it.name.contains("SentryUpload")
}
tasksToSkip.all { enabled = false }
}
@MohammadAzimi
MohammadAzimi / FastList.tsx
Created January 12, 2023 19:26 — forked from derekstavis/FastList.tsx
Discord's FastList, but in TypeScript
import { forEachObjIndexed } from "ramda";
import * as React from "react";
import {
Animated,
ScrollView,
View,
ViewStyle,
LayoutChangeEvent,
NativeScrollEvent,
} from "react-native";
Git hooks happen or trigger on an action like commit, push, merge, ...
We use them to prevent somethings like checking config.username to be or not to be something,
making some changes like linting the code or sending some reports and stuffs,
or check whether every thing is under controll following the project rules and structures like prevent commiting changes in specific files.
All of these are done by writing scripts.
scripts that resolves with 0 means everything is fine, and any other code means error!
git commit --no-verify ignores the hook
TRY TO USE HUSKY :)
{
"compilerOptions": {
/* Basic Options */
"target": "es2017", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
// "module": "es2015", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"lib": ["es6"], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
"jsx": "react-native", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
@MohammadAzimi
MohammadAzimi / CallbackToPromiseExample.js
Created March 11, 2022 16:38
example of converting callback function to promise
const popInitialNotificationPromise = () =>
new Promise((resolve, reject) => {
PushNotification.popInitialNotification((notification) => {
if (notification) {
resolve(notification);
} else {
resolve(undefined);
}
});
});
from https://github.com/react-native-svg/react-native-svg#path
<path />:
The element is used to define a path.
The following commands are available for path data:
M = moveto
L = lineto
H = horizontal lineto
V = vertical lineto
// 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 09:28
android network_security_config file for react-native. should be added to android/app/src/main/res/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 January 6, 2021 08:19
server tricks in react js
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]
@MohammadAzimi
MohammadAzimi / DeviceDetector.js
Last active January 28, 2022 15:06
Helper methods and functions - ReactNative, ReactJS, ReactNativeWeb and Monorepo design pattern for single source of code
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;