Skip to content

Instantly share code, notes, and snippets.

View phpsmarter's full-sized avatar

ReactSmarter phpsmarter

View GitHub Profile
function (root, args, context, info) {
return __awaiter(_this, void 0, void 0, function () {
var fragments, document, result;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
fragments = Object.keys(info.fragments).map(function (fragment) { return info.fragments[fragment]; });
document = {
kind: graphql_1.Kind.DOCUMENT,
definitions: [info.operation].concat(fragments),
function delay(milliseconds: number, count: number): Promise<number> {
return new Promise<number>(resolve => {
setTimeout(() => {
resolve(count);
}, milliseconds);
});
}
// async function always returns a Promise
async function dramaticWelcome(): Promise<void> {
+ // @flow
import React from "react";
import gql from "graphql-tag";
import { graphql } from "react-apollo";
+ import type { OperationComponent } from "react-apollo";
export const HERO_QUERY = gql`
query GetCharacter($episode: Episode!) {
hero(episode: $episode) {
name
id
import { ChildProps } from "react-apollo";
const withCharacter = graphql<Response, InputProps>(HERO_QUERY, {
options: ({ episode }) => ({
variables: { episode }
})
});
class Character extends React.Component<ChildProps<InputProps, Response>, {}> {
render(){
const Input = rc.compose(
- rc.withProps({component: "input", type: "text"}),
- rc.componentFromProp,
+ rc.componentFromProp,
+ rc.withProps({component: "input", type: "text"}),
)("component")
@phpsmarter
phpsmarter / ramda
Created March 26, 2018 00:39 — forked from raine/ramda
Browse Ramda documentation in Terminal
#!/usr/bin/env bash
# Browse Ramda documentation in Terminal
# Requires jq and a tool such as fzf or peco for interactive filtering
LATEST="http://raine.github.io/ramda-json-docs/latest.json"
DOCS_URL="http://ramdajs.com/docs/"
json=$(curl -s $LATEST)
functions=$(echo "$json" | jq -r '.[] | if .sig and (.sig | length > 0) then .name + " :: " + .sig else .name end')
@phpsmarter
phpsmarter / typescriptsheet.ts
Last active April 29, 2018 04:00
typescript cheatsheet
any
void
boolean
number
string
null
undefined
@phpsmarter
phpsmarter / 02_anonymous_user.js
Created March 27, 2018 08:04 — forked from tricoder42/02_anonymous_user.js
2017/06/06 [Medium] Use Selectors in Redux for Great Good
const initialState = {
user: {
name: 'anonymous',
token: null
}
}
const getUser = state => state.user || {}
const isAuthenticated = state => Boolean(getUser(state).token)
const isAnonymous = state => !isAuthenticated(user)
import * as R from 'ramda'
const initialState = {
user: {
name: 'jack',
token: 111111
},
goods: {
slug: 1,
@phpsmarter
phpsmarter / 多重背景的设置.js
Created March 27, 2018 23:56
多重背景的设置
html{
background:url("moon.jpg") no-repeat 100% 1em,
url("stars.jpg") repeat-x 0 0,
url("city.png") repeat-x bottom,
linear-gradient(black,#444);
background-color:#222;
min-height:100%;
}