Skip to content

Instantly share code, notes, and snippets.

View mvbattan's full-sized avatar

Batu mvbattan

  • Buenos Aires
View GitHub Profile
@mvbattan
mvbattan / actions.js
Created December 11, 2017 17:28
Targeted actions
const privateActionCreators = {
getMatchesSuccess: matchList => ({
type: actions.GET_MATCHES_SUCCESS,
payload: matchList,
target: 'matches'
}),
getMatchesError: error => ({
type: actions.GET_MATCHES_ERROR,
payload: error,
target: 'matches'
@mvbattan
mvbattan / reducer.js
Last active July 19, 2019 19:57
createReducer
function createReducer(initialState, reducerObject) {
return (state = initialState, action) => (
(reducerObject[action.type] && reducerObject[action.type](state, action)) || state;
);
}
export default createReducer(initialState, reducerDescription);
@mvbattan
mvbattan / reducer.js
Last active June 4, 2018 15:29
Reducer description
const reducerDescription = {
[actions.GET_MATCHES]: (state, action) => ({ ...state, matchesLoading: true }),
[actions.GET_MATCHES_SUCCESS]: (state, action) => ({
...state,
matchesLoading: false,
matchesError: null,
matches: action.payload
}),
[actions.GET_MATCHES_FAILURE]: (state, action) => ({
...state,
@mvbattan
mvbattan / reducer.js
Last active December 5, 2018 14:48
Disable complexity
import { actions } from './actions';
const initialState = {
matches: [],
matchesLoading: false,
matchesError: null,
pitches: [],
pitchesLoading: false,
pitchesError: null
};
@mvbattan
mvbattan / actions.js
Created December 11, 2017 15:15
privateActionCreators
import SoccerService from '../services/SoccerService';
export const actions = createTypes([
'GET_MATCHES',
'GET_MATCHES_SUCCESS',
'GET_MATCHES_FAILURE',
'GET_PITCHES',
'GET_PITCHES_SUCCESS',
'GET_PITCHES_FAILURE'
], '@SOCCER');
@mvbattan
mvbattan / pulgassaltarinas.py
Last active November 27, 2017 22:59
Pulgas Saltarinas por backtracking !
#!/usr/bin/python3
import sys
from time import time
from math import sqrt
from random import uniform
UP = 0
RIGHT = 1
DOWN = 2
@mvbattan
mvbattan / PointsPath.js
Created April 7, 2017 16:01
createLine
export const createLine = (dist, angle, color, opacity, startingPoint) => {
return {
backgroundColor: color,
height: 4,
width: dist,
bottom: dist * Math.sin(angle) / 2 + startingPoint.y,
left: -dist * (1 - Math.cos(angle)) / 2 + startingPoint.x,
position: 'absolute',
opacity,
transform: [
@mvbattan
mvbattan / PointsPath.js
Created April 7, 2017 15:56
createPoint
export const createPoint = (coordinates, color, size = 8) => {
return {
backgroundColor: color,
left: coordinates.x - 3,
bottom: coordinates.y - 2,
position: 'absolute',
borderRadius: 50,
width: size,
height: size
};
@mvbattan
mvbattan / index.js
Last active April 13, 2017 14:22
index.js - full
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View
} from 'react-native';
import SeparatorsLayer from './SeparatorsLayer';
import PointsPath from './PointsPath';
@mvbattan
mvbattan / index.js
Last active April 13, 2017 14:17
index.js - v3
import SeparatorsLayer from './SeparatorsLayer';
import PointsPath from './PointsPath';
import { Point } from './pointUtils';
import { startingPoint, vectorTransform } from './Scaler';
const lightBlue = '#40C4FE';
const green = '#53E69D';
const lightBluePoints = [Point(0, 0), Point(1, 2), Point(2, 3), Point(3, 6), Point(5, 6)];
const greenPoints = [Point(0, 2), Point(3, 4), Point(4, 0), Point(5, 10)];