Skip to content

Instantly share code, notes, and snippets.

View phpsmarter's full-sized avatar

ReactSmarter phpsmarter

View GitHub Profile
@phpsmarter
phpsmarter / faceDection.html
Created March 29, 2018 00:24
google FaceDection
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Live Face Detector</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.error-msg {
@phpsmarter
phpsmarter / hoc-svg.ts
Created March 28, 2018 00:20
react svg con
const {
withStateHandlers,
} = Recompose;
console.clear();
const CANVAS_WIDTH = 640;
const CANVAS_HEIGHT = 480;
const CIRCLE_RADIUS = 48;
@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%;
}
import * as R from 'ramda'
const initialState = {
user: {
name: 'jack',
token: 111111
},
goods: {
slug: 1,
@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)
@phpsmarter
phpsmarter / typescriptsheet.ts
Last active April 29, 2018 04:00
typescript cheatsheet
any
void
boolean
number
string
null
undefined
@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')
const Input = rc.compose(
- rc.withProps({component: "input", type: "text"}),
- rc.componentFromProp,
+ rc.componentFromProp,
+ rc.withProps({component: "input", type: "text"}),
)("component")
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(){
+ // @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