Skip to content

Instantly share code, notes, and snippets.

@kiok46
kiok46 / Designing_Distributed_Systems.md
Last active January 23, 2020 14:52
Designing Distributed Systems

The sidecar pattern

The sidecar pattern is a singlenode pattern made up of two containers. The first is the application container. It con‐ tains the core logic for the application. Without this container, the application would not exist. In addition to the application container, there is a sidecar container. The role of the sidecar is to augment and improve the application container, often without the application container’s knowledge.

Adding HTTPS to a Legacy Service

@kiok46
kiok46 / xpo
Created May 20, 2019 21:57
Verify myself: 16697699bc564ae385a4a0758fd4ea44 http://blockchain-devs.xpo.network #
Verify myself: 16697699bc564ae385a4a0758fd4ea44 http://blockchain-devs.xpo.network #
// Multiple Tap Handler
const multipleTapHandler = (func, wait = 200) => {
let tapCount = 0
let handler;
return function() {
//console.log(tapCount)
if (tapCount === 0){
tapCount++;
func()
}
@kiok46
kiok46 / MultiTapHandlerWithReactExample.js
Created June 10, 2018 12:31
Preventing React-Navigation Multiple Screen Instances
import React, { Component } from 'react';
import { TouchableOpacity } from 'react-native';
import PropTypes from 'prop-types';
import multipleTapHandler from 'multipleTapHandler';
class Button extends Component {
render() {
return (
<TouchableOpacity
{...this.props}
@kiok46
kiok46 / ReduxCustomTextInput.js
Created June 10, 2018 11:54
Redux, Reactotron, Actions, Reducers and Sagas (2)
import React, { Component } from 'react';
import { AppRegistry, TextInput, View } from 'react-native';
import { connect } from 'react-redux';
import * as actions from '../redux/actions';
class CustomTextInput extends Component {
onTextChange = text => {
this.props.textChanged(text);
};
@kiok46
kiok46 / ReduxStore.js
Created June 10, 2018 11:53
Redux, Reactotron, Actions, Reducers and Sagas (2)
import { createStore, compose, applyMiddleware } from 'redux';
import createSagaMiddleware from 'redux-saga';
import { sagaMonitor } from '../../configs';
import reducers from '../reducers'; // Our Reducers
import rootSaga from '../sagas'; // Our Sagas
const middleWare = [];
// Setup Redux-Saga
const sagaMiddleware = createSagaMiddleware({ sagaMonitor });
@kiok46
kiok46 / ReduxReactotronConfigs.js
Created June 10, 2018 11:52
Redux, Reactotron, Actions, Reducers and Sagas (2)
import Reactotron from 'reactotron-react-native';
import sagaPlugin from 'reactotron-redux-saga';
import apisaucePlugin from 'reactotron-apisauce';
Reactotron.configure({ name: 'GiftCard' })
.useReactNative()
.use(apisaucePlugin())
.use(sagaPlugin());
Reactotron.connect(); // Connect with reactotron
@kiok46
kiok46 / ReduxTextInputSaga.js
Created June 10, 2018 11:51
Redux, Reactotron, Actions, Reducers and Sagas (2)
import { put, take, fork } from 'redux-saga/effects';
import { TEXT_CHANGED, TEXT_CHANGED_SUCCESS } from '../types';
// ****************
// WORKERS
// ****************
function* workerTextChanged(action) {
console.log(action);
// {type: "text_changed", payload: "-_-"}
@kiok46
kiok46 / ReduxSagaIndex.js
Created June 10, 2018 11:50
Redux, Reactotron, Actions, Reducers and Sagas (2)
import { all, fork } from 'redux-saga/effects';
import CustomTextInputSagas from './CustomTextInputSagas';
export default function* rootSaga() {
yield all([
fork(CustomTextInputSagas.watcherTextChanged),
]);
}
@kiok46
kiok46 / Redux CustomTextInputActions.js
Created June 10, 2018 11:48
Redux, Reactotron, Actions, Reducers and Sagas (2)
import { TEXT_CHANGED } from '../types';
export const textChanged = text => {
return {
type: TEXT_CHANGED,
payload: text
};
};