Skip to content

Instantly share code, notes, and snippets.

View phpsmarter's full-sized avatar

ReactSmarter phpsmarter

View GitHub Profile
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 / 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
@phpsmarter
phpsmarter / login.apollo.js
Created February 20, 2018 00:26
apollo-client mutation
signup = async () => {
const { email, password } = this.state;
try {
const result = await this.props.signupUserMutation({
variables: {
email,
password,
},
});
@phpsmarter
phpsmarter / querycomponent.js
Created February 20, 2018 02:10
query components
import gql from 'graphql-tag';
import { Query } from 'react-apollo';
const query = gql`
query SomeQuery {
foo {
bar
baz
}
}
@phpsmarter
phpsmarter / graphql-yoga-todo.js
Created February 21, 2018 13:39
graphql-yoga-simple-todo
const { GraphQLServer } = require('graphql-yoga');
let count = 2;
let todos = [{
id: '0',
content: 'Buy milk',
isCompleted: true
},
{
id: '1',
@phpsmarter
phpsmarter / Faq-item.json
Last active February 22, 2018 07:08
f8app-datamodel
{
"_id" : "Rc3e0u89Ao",
"answer" : "If you require special assistance, auxiliary aids, or other reasonable accommodations to fully participate in this event, please email [email protected]. Information regarding disabilities and special assistance will remain confidential.",
"question" : "Are there accommodations for people with disabilities and those requiring special assistance?",
"_updated_at" : ISODate("2016-10-07T18:46:01.032+0000"),
"_created_at" : ISODate("2016-10-07T18:46:01.032+0000")
}
@phpsmarter
phpsmarter / AsyncStorage-async-awati.js
Last active February 23, 2018 09:21
AsyncStorage async/await
import { AsyncStorage } from 'react-native';
// retrieve
export const retrieve = async (key) => await AsyncStorage.getItem(key);
// store
export const store = async (key, value) => {
await AsyncStorage.setItem(key, value);
}
@phpsmarter
phpsmarter / app.js
Last active February 23, 2018 11:30
Apollo-Mongodb-Server
const express = require('express');
const bodyParser = require('body-parser');
const Mongoose = require('mongoose');
const PORT = 8080;
const app = express();
const { apolloExpress, graphiqlExpress } = require('apollo-server');
const { makeExecutableSchema } = require('graphql-tools');
Mongoose.Promise = global.Promise;
@phpsmarter
phpsmarter / RNAP-init.js
Created February 23, 2018 12:59
非常好的配置方法
import { ApolloClient, createNetworkInterface } from 'react-apollo';
import { SubscriptionClient } from 'subscriptions-transport-ws';
import { addGraphQLSubscriptions } from 'add-graphql-subscriptions';
import { AsyncStorage } from 'react-native';
import { SERVER_ENDPOINT, SERVER_SUBSCRIPTION_ENDPOINT } from 'env';
let apolloClient = null;
const create = async (initialState = {}) => {
const token = await AsyncStorage.getItem('token');
@phpsmarter
phpsmarter / airbnb_datamodel.js
Last active February 25, 2018 00:58
Prisma|airbnb_datamodel
type User {
id: ID! @unique
createdAt: DateTime!
updatedAt: DateTime!
firstName: String!
lastName: String!
email: String! @unique
password: String!
phone: String!
responseRate: Float