Skip to content

Instantly share code, notes, and snippets.

View andriangungon's full-sized avatar

andriangungon

View GitHub Profile
import _ from 'lodash';
// -- ui
import React, { useEffect, useState } from 'react';
import { View, TouchableOpacity, Text } from 'react-native';
import StarRating from 'components/rating_screen/star_rating';
import RatingQuestionnaires from 'components/rating_screen/rating_questionnaires'
import ActionSheetModal from 'components/action_sheet_modal';
import PropTypes from 'prop-types';
import React from 'react';
import { DefaultTheme, NavigationContainer } from '@react-navigation/native';
import MainNavigator from './main.navigator';
import { navigationRef } from './root_navigation';
/*
* Navigation theming: https://reactnavigation.org/docs/en/next/themes.html
*/
const navigatorTheme = {
...DefaultTheme,
const loadingReducer = (state = {}, action) => {
const { type } = action;
const matches = /(.*)_(START|SUCCESS|FAIL)/.exec(type);
// not a *_START / *_SUCCESS / *_FAILURE actions, so we ignore them
if (!matches) return state;
const [, requestName, requestState] = matches;
return {
...state,
this.props.navigation.state.routeName
let token = bearerHeader.split(' ')[1];
@andriangungon
andriangungon / bet_controller.js
Last active March 9, 2021 15:51
I used this in nodejs-lotto project
//function without try and catch will work but it immitates the behavior of try and catch block
exports.create = async (req, res) => {
let params = req.body;
params = { ...params, draw_date: getDateAndYear() };
const filter = { user_id: params.user_id };
const { coins } = await User.findOne(filter).select('coins');
if (coins >= BET_AMOUNT) {
module.exports = function isLoggedIn(req, res, next) {
if (req.user) {
next();
} else {
// return unauthorized
res.send(401, "Unauthorized");
}
};
brew upgrade php
function HomeScreen({ navigation }) {
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Text>Home Screen</Text>
<Button
title="Go to Details"
onPress={() => {
/* 1. Navigate to the Details route with params */
navigation.navigate('Details', {
itemId: 86,
Step 1: just open terminal and run or ctl + c to stop and save
xcrun simctl io booted recordVideo filename.mp4