Skip to content

Instantly share code, notes, and snippets.

View FreddyPoly's full-sized avatar
🍎

Frédéric Llorca FreddyPoly

🍎
  • 04:16 (UTC +02:00)
View GitHub Profile
@FreddyPoly
FreddyPoly / Activity Indicator.js
Last active June 12, 2017 09:11
[REACT NATIVE] Activity Indicator Overlay
this.state = {
animating: false,
};
_startLoading = (bool) => new Promise((resolve) => {
this.setState({animating: bool});
resolve(bool);
})
<View
@FreddyPoly
FreddyPoly / array.js
Created May 16, 2017 15:13
[JAVASCRIPT] Remove single element from array
// On cherche l'index de l'élément à supprimer (ici un objet)
const index = array.indexOf(leg);
// In exécute la méthode slice si l'index n'est pas -1
// Le deuxième argument est le nombre d'éléments à supprimer
if (index !== -1) array.splice(index, 1);
// Solution à faible performance car la méthode 'slice' est très couteuse
// Si besoins de performances alors utiliser une autre structure de données qu'un Array
@FreddyPoly
FreddyPoly / component.js
Created May 29, 2017 14:56
[REACT NATIVE] Display / Hide Components
render(){
return(
{yourCondition ? <yourComponent /> : null}
{ this.state.btn_state ? <View>
{this.state.list_options}
</View> : null }
)
}
@FreddyPoly
FreddyPoly / component.js
Last active August 9, 2017 08:35
[REACT NATIVE] Mesure de performances
import PerfMonitor from 'react-native/Libraries/Performance/RCTRenderingPerf';
componentDidMount() {
PerfMonitor.toggle();
setTimeout(() => {
PerfMonitor.start();
setTimeout(() => {
PerfMonitor.stop();
}, 25000);
}, 5000);
@FreddyPoly
FreddyPoly / fichier.js
Created June 22, 2017 15:34
[JAVASCRIPT] Displaying content of every field of an object
const keys = Object.keys(obj);
keys.map((key) => {
console.log(`'${key}' : ${obj[key]}`);
});
@FreddyPoly
FreddyPoly / BurgerMenu.js
Last active June 28, 2017 09:08
[REACT NATIVE] Navigation
import React, { Component } from 'react';
import {StyleSheet, TouchableOpacity, Image} from 'react-native';
import { THEME } from '../config/env';
class BurgerMenu extends Component {
constructor(props) {
super(props);
}
@FreddyPoly
FreddyPoly / iOS-Problem.txt
Last active July 10, 2017 15:16
[REACT NATIVE IOS] React/RCT... file not found
Clean (cmd+shift+K)
Build core React - select React as the scheme in Xcode and build it (cmd+B)
Build the library that is failing (e.g. RCTText).
Build your app (CMD + R)
@FreddyPoly
FreddyPoly / component.js
Created July 11, 2017 14:17
[REACT NATIVE] Adding custom font
1. Get the fonts (.ttf)
2. Paste the fonts in `./src/assets/fonts/`
3. In `package.json` add:
“rnpm”: {
“assets”: [“./src/assets/fonts”]
}
4. Run `react-native link`
@FreddyPoly
FreddyPoly / terminal
Last active April 9, 2021 20:38
[REACT NATIVE] Get SHA1
Debug SHA1 (root of project)
keytool -J-Duser.language=en -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
Release SHA1 (/android/app/)
keytool -J-Duser.language=en -list -v -keystore mystore.keystore
@FreddyPoly
FreddyPoly / Terminal
Last active May 27, 2021 20:03
[REACT NATIVE] Check memory usage of app
Plutôt utiliser l'outil `Profiler` de Android Studio. Les valeurs données sont différentes.
adb shell dumpsys meminfo <package name | pid> [-d]
adb shell dumpsys meminfo com.awesomeproject [-d]
while sleep 1; do adb shell dumpsys meminfo com.cnhrtkapp | grep 'Unknown\|Gfx dev\|TOTAL'; done