Skip to content

Instantly share code, notes, and snippets.

View sbycrosz's full-sized avatar
💭
I may be slow to respond.

Sam Aryasa sbycrosz

💭
I may be slow to respond.
View GitHub Profile
/** @type {import('tailwindcss').Config} */
const plugin = require('tailwindcss/plugin');
const reduce = require('lodash/reduce');
const isString = require('lodash/isString');
function wrapUtilities(utilities) {
// Hack to enable AutoCompletion on VSCode
// https://github.com/tailwindlabs/tailwindcss-intellisense/issues/227#issuecomment-1139895799
return reduce(
utilities,
@sbycrosz
sbycrosz / export-fastlane-match.rb
Created September 20, 2022 03:03
Export fastlane match signing credentials for AppCenter
# Export iOS code signing as p12 and mobileprovision file for usage in Appcenter
# Manual decryption as described on https://docs.fastlane.tools/actions/match/
desc "Export fastlane match signing credentials for AppCenter"
lane :export_code_signing do
ensure_env_vars(
env_vars: [
"MATCH_GIT_URL",
"MATCH_PASSWORD",
]
@sbycrosz
sbycrosz / RNNFCPassportReader.m
Last active June 9, 2021 04:51
React Native bridge for AndyQ/NFCPassportReader
//
// NFCPassportReader.m
// StashawayApp
//
// Created by Sam Aryasa on 3/6/20.
// Copyright © 2020 Facebook. All rights reserved.
//
#import "React/RCTBridgeModule.h"
@sbycrosz
sbycrosz / HierarchylessDetoxReporter.js
Last active December 6, 2020 19:36
Custom jest reporter for wix/detox that surpress printing of the entire page's UI hierarchy on failed spec
// HierarchylessDetoxReporter.js
// Custom jest reporter for wix/detox that surpress printing of the entire page's UI hierarchy on failed spec
// Github issue: https://github.com/wix/Detox/issues/992
// Usage (in your jest config): "reporters": ["./e2e/HierarchylessDetoxReporter.js"],
const StreamlineReporter = require('detox/runners/jest/streamlineReporter');
const HIERARCHY_REGEX_TRIMMER = /[\s\S]+?(?=Hierarchy)/;
class HierarchylessDetoxReporter extends StreamlineReporter {
@sbycrosz
sbycrosz / SimpleReducer_CombinedAPI.js
Created March 8, 2018 07:38
SimpleReducer_CombinedAPI.js
// components/todos/index.js
import { connect } from 'react-redux';
import Todos from './Todos';
import { createLoadingSelector } from '../../redux/api/selectors';
// Show loading when any of GET_TODOS_REQUEST, GET_USER_REQUEST is active
const loadingSelector = createLoadingSelector(['GET_TODOS', 'GET_USER']);
const mapStateToProps = (state) => ({ isFetching: loadingSelector(state) });
export default connect(mapStateToProps)(Todos);
@sbycrosz
sbycrosz / SimpleReducer_ErrorReducer.js
Last active February 18, 2020 14:14
SimpleReducer_ErrorReducer.js
// api/errorReducer.js
export const errorReducer = (state = {}, action) => {
const { type, payload } = action;
const matches = /(.*)_(REQUEST|FAILURE)/.exec(type);
// not a *_REQUEST / *_FAILURE actions, so we ignore them
if (!matches) return state;
const [, requestName, requestState] = matches;
return {
@sbycrosz
sbycrosz / SimpleReducer_RefactoredReducer.js
Created March 8, 2018 07:26
SimpleReducer_RefactoredReducer.js
// todo/reducer.js
const initialState = { todos: [] };
export const todoReducer = (state = initialState, action) => {
switch(action.type) {
case 'GET_TODOS_SUCCESS':
return { ...state, todos: action.payload };
default:
return state;
}
};
@sbycrosz
sbycrosz / SimpleReducer_ConnectedComponent.js
Last active March 8, 2018 09:13
SimpleReducer_ConnectedComponent.js
// api/selectors.js
import _ from 'lodash';
export const createLoadingSelector = (actions) => (state) => {
// returns true only when all actions is not loading
return _(actions)
.some((action) => _.get(state, `api.loading.${action}`));
};
// components/todos/index.js
import { connect } from 'react-redux';
@sbycrosz
sbycrosz / SimpleReducer_LoadingReducer.js
Last active May 4, 2020 14:24
SimpleReducer_LoadingReducer.js
// api/loadingReducer.js
const loadingReducer = (state = {}, action) => {
const { type } = action;
const matches = /(.*)_(REQUEST|SUCCESS|FAILURE)/.exec(type);
// not a *_REQUEST / *_SUCCESS / *_FAILURE actions, so we ignore them
if (!matches) return state;
const [, requestName, requestState] = matches;
@sbycrosz
sbycrosz / SimpleReducer_AsyncInRedux.js
Created March 8, 2018 07:16
SimpleReducer_AsyncInRedux.js
// todo/actions.js
export const getTodos = (dispatch) => () => {
dispatch({ type: 'GET_TODOS_REQUEST' });
return fetch('/api/v1/todos')
.then((todos) => dispatch({ type: 'GET_TODOS_SUCCESS', payload: todos })
.catch((error) => dispatch({ type: 'GET_TODOS_FAILURE', payload: error, error: true });
};
// todo/reducer.js
const initialState = { todos: [] };