Skip to content

Instantly share code, notes, and snippets.

View Mannaio's full-sized avatar

Tommaso Mannaio

View GitHub Profile
.then(res => {
const {
matchsPlayed: { home: teamsMatchsPlayedHome, away: teamsMatchsPlayedAway},
wins: { home: teamsStatsWinHome, away: teamsStatsWinAway },
draws: { home: teamsStatsDrawHome, away: teamsStatsDrawAway },
loses: { home: teamsStatsLoseHome, away: teamsStatsLoseAway }
} = res.data.api.statistics.matchs;
const teamStats = {
teamsMatchsPlayedHome,
teamsMatchsPlayedAway,
@Mannaio
Mannaio / index.html
Created April 22, 2017 19:34
Using CSS variables with styled components 💅
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Styled Components</title>
</head>
<body>
<div id="main">
<!-- This is where our React app will go -->
</div>
// The action
export function increase(index) {
return {
type: 'INCREMENT_COORDINATES',
index
}
}
// Redux
case 'INCREMENT_COORDINATES' :
console.log("incrementing coordinates")
const a = action.index;
let string = state[a].d
let array = string.split(' ')
let num = 5
let neWd = array.map(x => x === 'M' || x === 'L' ? x : +x + 5).join(' ')
console.log(neWd)
return [
...state.slice(0,a), // before the one we are updating
import React from 'react';
import Chart from './Chart';
import LineChart from './d3/LineChart';
export default class ChartsGrid extends React.Component{
render() {
const view = [480, 320];
const trbl = [0, 0, 0, 0]
@Mannaio
Mannaio / index.html
Created November 26, 2016 17:12
redux-tabulate-1.0.0-alpha
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<div class="container-fluid" id="js-app">
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.0.2/react.min.js"></script>
<script src="https://fb.me/react-dom-15.0.2.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/redux/3.5.2/redux.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/redux-thunk/2.0.1/redux-thunk.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-redux/4.4.5/react-redux.min.js"></script>
@Mannaio
Mannaio / index.html
Last active December 5, 2016 09:53
react-d3-line-chart-basic
<div
id="js-app"
onClick="addData()"
></div>
<p>Click chart to add new value</p>
import React from 'react';
export default class Manna extends React.Component {
InitVal = {
likes: 10,
code: "2",
size: 350,
d1: 1,
d2: .6875,
const svgs = [
{
"code":"BAcyDyQwcXX",
"viewBox":"0 0 70 70",
"w": "70",
"h": "70",
"fill" : "none",
"strokewidth": "1",
"stroke": "red",
"d": "M 35 0 L 37.51521614737791 11.069316892700925 A 24.0625 24.0625 0 0 1 54.46697142714717 20.856417366712364 L 65.31088913245536 17.500000000000004 L 56.982187574525085 25.21289952598856 A 24.0625 24.0625 0 0 1 56.982187574525085 44.78710047401144 L 65.31088913245536 52.5 L 54.46697142714717 49.143582633287636 A 24.0625 24.0625 0 0 1 37.51521614737791 58.930683107299075 L 35 70 L 32.484783852622094 58.930683107299075 A 24.0625 24.0625 0 0 1 15.533028572852828 49.143582633287636 L 4.689110867544645 52.5 L 13.017812425474919 44.787100474011446 A 24.0625 24.0625 0 0 1 13.017812425474911 25.21289952598857 L 4.689110867544649 17.499999999999996 L 15.533028572852828 20.856417366712368 A 24.0625 24.0625 0 0 1 32.484783852622094 11.069316892700922"
var fs = require('fs')
var React = require('react')
var ReactDOMServer = require('react-dom/server')
var Manna = require('./Manna')
var Cog = require('./Cog')
var build = function(name, props) {
props.size = props.size || 64
var size = props.size