Skip to content

Instantly share code, notes, and snippets.

View terrysahaidak's full-sized avatar

Terry Sahaidak terrysahaidak

View GitHub Profile
@terrysahaidak
terrysahaidak / setupProxy.js
Created November 12, 2019 15:35
CRA Proxy
const createProxy = require('http-proxy-middleware');
const proxy = createProxy({
target: 'https://apiko-marketplace-api-2019.herokuapp.com/',
pathRewrite: {
'^/api': '',
},
changeOrigin: true,
});
@terrysahaidak
terrysahaidak / OnLoad.cpp
Last active October 26, 2019 15:04
Android JSI OnLoad.cpp with reanimated bindings
// Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
#include <fb/fbjni.h>
#include <folly/Memory.h>
#include <jsi/JSCRuntime.h>
#include <jsi/JSIDynamic.h>
#include <jsireact/JSIExecutor.h>
import React, { Component } from 'react';
import { Text, View } from 'react-native';
import { inject } from 'mobx-react';
const RootSpinner = () => <Text>Loading</Text>;
const EmptyCover = ({ retry }) => (
<View>
<Text>Error</Text> <Text onPres={retry}>Retry</Text>
</View>
);
@terrysahaidak
terrysahaidak / mobx-react.js
Created July 1, 2019 12:58
mobx-react inject/provider with hooks
import React, { useContext, forwardRef } from 'react';
const MSTContext = React.createContext(null);
// eslint-disable-next-line prefer-destructuring
export const Provider = MSTContext.Provider;
export function useMst(mapStateToProps) {
const store = useContext(MSTContext);
@terrysahaidak
terrysahaidak / javascript.json
Created May 28, 2019 17:24
JavaScript snippets
{
// Place your snippets for javascript here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
@terrysahaidak
terrysahaidak / setupProxy.js
Last active May 21, 2019 11:14
Proxy for CRA (Apiko courses 2019)
const createProxy = require('http-proxy-middleware');
const proxy = createProxy({
target: 'https://apiko-marketplace-api-2019.herokuapp.com/',
pathRewrite: {
'^/api': '',
},
changeOrigin: true,
});
@terrysahaidak
terrysahaidak / useSuspendedProp.js
Created May 10, 2019 16:59
Useful hook to suspend your prop change
export default function useSuspendedProp(prop, timeout = 500) {
const initialValue = useRef(prop);
const [copy, setCopy] = useState(prop);
const timeoutRef = useRef(null);
useEffect(() => {
clearTimeout(timeoutRef.current);
if (
initialValue.current === prop &&
@terrysahaidak
terrysahaidak / launch.json
Created March 1, 2019 10:45
VSCode launch.json for React Native
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug Android",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
import React from 'react';
import {
StyleSheet,
Text,
View,
Button,
} from 'react-native';
import Reanimatable from './Reanimatable';
import A from 'react-native-reanimated';
@terrysahaidak
terrysahaidak / Pager.js
Last active November 28, 2018 09:58
Reanimated pager
import React, { Component } from 'react';
import {
Platform,
StyleSheet,
Text,
View,
Dimensions,
Alert,
} from 'react-native';
import A, { Easing } from 'react-native-reanimated';