Skip to content

Instantly share code, notes, and snippets.

View majirosstefan's full-sized avatar
🏠
Working from home

Stefan Majiros majirosstefan

🏠
Working from home
View GitHub Profile
@majirosstefan
majirosstefan / ISO-639-1-language.json
Created July 5, 2021 16:27 — forked from jrnk/ISO-639-1-language.json
ISO 639-1 Alpha-2 codes of languages JSON
[
{ "code": "aa", "name": "Afar" },
{ "code": "ab", "name": "Abkhazian" },
{ "code": "ae", "name": "Avestan" },
{ "code": "af", "name": "Afrikaans" },
{ "code": "ak", "name": "Akan" },
{ "code": "am", "name": "Amharic" },
{ "code": "an", "name": "Aragonese" },
{ "code": "ar", "name": "Arabic" },
{ "code": "as", "name": "Assamese" },
@majirosstefan
majirosstefan / app.js
Created July 30, 2021 22:19 — forked from johnmarinelli/app.js
Cavy + React Navigation (TabNavigator)
import { TabNavigator } from 'react-navigation'
import Ionicons from 'react-native-vector-icons/Ionicons'
import { hook } from 'cavy'
class Icon extends Component {
render() {
const { navigation, generateTestHook, routeName... } = this.props
return <Ionicons ref={generateTestHook(`Navigation.${routeName}`)} onPress={() => navigation.navigate(routeName)} .../>
}
}
@majirosstefan
majirosstefan / react-native-char-kit-animations.js
Created August 30, 2021 12:26
animations for react-native-chart-kit
import React, { useEffect, useState, useRef } from 'react';
import {
Dimensions, SafeAreaView,
ScrollView,
StatusBar, StyleSheet, useColorScheme, Animated,
LayoutAnimation,
View
} from 'react-native';
import { LineChart, ProgressChart } from 'react-native-chart-kit';
import { Colors } from 'react-native/Libraries/NewAppScreen';
@majirosstefan
majirosstefan / translate-JSON-files-with-Google-Cloud.js
Created September 10, 2021 11:17
This is a script to translate values in JSON values which I use to localization support for apps built in my own dev studio (stefan-majiros.com)
// follow the 💖 for important parts
const {createWriteStream} = require('fs');
// you need to install this lib: globally or locally
var TJO = require('translate-json-object')();
// 💖 feel free to use any other JSON file
var json_SOURCE_OF_TRUTH = require('../src/localization/translations/en.json');
import React, {Component} from 'react';
import {Dimensions, StyleSheet, TouchableOpacity, View} from 'react-native';
import {RNCamera} from 'react-native-camera';
import {launchImageLibrary} from 'react-native-image-picker';
import {QRreader} from 'react-native-qr-decode-image-camera';
import QRCodeScanner from 'react-native-qrcode-scanner';
import Ionicon from 'react-native-vector-icons/Ionicons';
export default class CameraScaningScreen extends Component {
scanner;
import {TestScope} from 'cavy';
export default function (scope: TestScope) {
// 🚀
const screen = (await scope.findComponent('CameraScanningScreen')) as any;
await scope.pause(1000);
// 🚀 now you can call the method directly
screen.onSuccessScan({data: "vaccCY2x..."});
}
@majirosstefan
majirosstefan / testable.tsx
Created September 19, 2021 09:44
Cavy e2e React Native Test Utility
import {useCavy, wrap} from 'cavy';
import React from 'react';
export function testable<P>(
FunctionalComponent: React.FunctionComponent<P>,
): React.FunctionComponent<P & {testID?: string}> {
// if (!__DEV__) {
// return FunctionalComponent;
// }
"e2e:ios": "cavy run-ios",
"e2e:android": "cavy run-android --verbose --xml"
# Firebase Config using base64
echo "Injecting secrets..."
echo "Updating Google JSON"
echo $GoogleServicesJson | base64 --decode >"$APPCENTER_SOURCE_DIRECTORY/android/app/google-services.json"
echo "Updating Google plist"
echo $GoogleServicesPlist | base64 --decode >"$APPCENTER_SOURCE_DIRECTORY/ios/GoogleService-Info.plist"
echo "Finished injecting secrets..."
echo "Google Services"
cat "$APPCENTER_SOURCE_DIRECTORY/ios/GoogleService-Info.plist"
if [ -z ${RUN_E2E_TESTS+x} ]; then
echo "E2E are not turned on for this build."
exit 0 // calling exit with 0 will skip further execution of script
// also, exit 1 is similar to exception
fi