Skip to content

Instantly share code, notes, and snippets.

View phpsmarter's full-sized avatar

ReactSmarter phpsmarter

View GitHub Profile
@phpsmarter
phpsmarter / booking-service-api.raml
Created February 17, 2018 11:36 — forked from crizstian/booking-service-api.raml
Example of a raml file
#%RAML 1.0
title: Booking Service
version: v1
baseUri: /
types:
Booking:
properties:
city: string
cinema: string
dashboard "Food":
- h1 text: Food
- h2 text: By caloric content
- 3 columns:
- rows:
- h3 text: Bananas
- pie chart: {
"columns": [
["Protein", 5], ["Sugar", 10], ["Other carbs", 40], ["Fat", 1]
]
@phpsmarter
phpsmarter / transducer-rxjs-ramda.js
Created January 25, 2018 03:28 — forked from michiel/transducer-rxjs-ramda.js
transducer in es6 with ramda and rxjs
const Rx = require('rx');
const R = require('ramda');
const seq = Rx.Observable.range(1, 10);
const isEven = (x) => x % 2 === 0;
const add1 = (x) => x + 1;
const transducer = R.compose(
R.map(add1),
@phpsmarter
phpsmarter / compose-async.js
Created January 23, 2018 19:37 — forked from export-mike/compose-async.js
compose utility function for async await, A team effort with @cameronbourke and @gwyneplaine. It was a fun discussion.
/*
* Requires Node 8+
* Works in chrome, simply copy and paste into console.
*/
const R = require('ramda');
const compose =
(...funcs) =>
(...args) =>
funcs.reduceRight(async (a, f) => {
@phpsmarter
phpsmarter / gql-apollo-test.spec.js
Created January 20, 2018 02:27 — forked from shlomitc/gql-apollo-test.spec.js
A working example of graphql and apollo client test
import 'mocha';
import {expect} from 'chai';
import 'isomorphic-fetch';
import ApolloClient from 'apollo-client';
import gql from 'graphql-tag';
import {print} from 'graphql-tag/bundledPrinter';
describe('some test', () => {
it('should pass', () => {
```
const { Component } = React;
const { mapProps } = Recompose;
const User = ({ name, status }) =>
<div className="User">{ name }—{ status }</div>;
const UserList = ({ users, status }) =>
<div className="UserList">
<h3>{ status } users</h3>
import React, { Component } from 'react';
import { graphql } from 'react-apollo';
import { MatchSummary, NoDataSummary } from '@mls-digital/react-components';
import MatchSummaryQuery from './match-summary.graphql';
const mapResultsToProps = ({ data }) => {
if (!data.match)
return {
loading: data.loading,
};
import { get } from 'lodash';
import { withRouter } from 'react-router';
import { graphql } from 'react-apollo';
import { compose, mapProps } from 'recompose';
import jobListQuery from './jobList.graphql';
function SomeBaseComponent() {
{/*... some component...*/}
}
@phpsmarter
phpsmarter / branch-complete-graphcool.jsx
Created January 16, 2018 10:21 — forked from idkjs/branch-complete-graphcool.jsx
refactored branch method with recompose from Medium Article
import React from 'react';
import { withState, pure, branch, renderComponent, compose } from 'recompose';
import { gql, graphql } from 'react-apollo';
// Define a very basic loading state component - you could make this
// a nice animation or something
const Loading = () => (
<div>Loading</div>
);
@phpsmarter
phpsmarter / import-books.js
Created January 16, 2018 10:20 — forked from idkjs/import-books.js
books-recompose import script for graphcool
const _ = require('lodash')
const { Lokka } = require('lokka')
const { Transport } = require('lokka-transport-http')
const debug = require('debug')('Transport')
const client = new Lokka({
transport: new Transport('https://api.graph.cool/simple/v1/graphcoolendpoint')
})