Skip to content

Instantly share code, notes, and snippets.

View chengcyber's full-sized avatar

Cheng Liu chengcyber

  • TikTok
  • San Jose
View GitHub Profile
@chengcyber
chengcyber / formikApollo.js
Created April 25, 2019 02:58 — forked from mwickett/formikApollo.js
Formik + Apollo
import React from 'react'
import { withRouter, Link } from 'react-router-dom'
import { graphql, compose } from 'react-apollo'
import { Formik } from 'formik'
import Yup from 'yup'
import FormWideError from '../elements/form/FormWideError'
import TextInput from '../elements/form/TextInput'
import Button from '../elements/form/Button'
import { H2 } from '../elements/text/Headings'
@chengcyber
chengcyber / debug.sh
Created November 27, 2018 02:16
further debug vim via profile
```
:profile start profile.log
:profile func *
:profile file *
" Do the slow operations here.
:profile pause
:qa!
```
@chengcyber
chengcyber / utils.js
Last active May 3, 2018 09:36
utility functions in javascript
/**
* debounce the target fn which be invoked only after not called again in a period of wait time
* if immediate is true, fn will invoked immediately, and can only be invoked again after wait time
*/
function debounce(fn, wait, immediate) {
var timeoutId = null
return function() {
var context = this
var args = arguments
var callNow = immediate && !timeoutId
/**
Code copyright Dustin Diaz and Ross Harmes, Pro JavaScript Design Patterns.
**/
// Constructor.
var Interface = function (name, methods) {
if (arguments.length != 2) {
throw new Error("Interface constructor called with " + arguments.length + "arguments, but expected exactly 2.");
}
this.name = name;
@chengcyber
chengcyber / triple-box-shadow.css
Created September 14, 2017 06:22
triple-box-shadow.css
footer:before {
content: '';
position: absolute;
right: 0;
bottom: 0;
left: 0;
height: 50px;
overflow: hidden;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2), 0 8px 0 -3px #f6f6f6, 0 9px 1px -3px rgba(0, 0, 0, 0.2);
}
@chengcyber
chengcyber / debugHOC.md
Created April 27, 2017 14:38
React Debug HOC
export function IIHOCDEBUGGER(WrappedComponent) {
  return class II extends WrappedComponent {
    render() {
      return (
        <div>
          <h2>HOC Debugger Component</h2>
          <p>Props</p> <pre>{JSON.stringify(this.props, null, 2)}</pre>
          <p>State</p><pre>{JSON.stringify(this.state, null, 2)}</pre>
 {super.render()}
@chengcyber
chengcyber / cloudSettings
Created March 15, 2017 06:04
Visual Studio Code Sync Settings Gist
{"lastUpload":"2017-03-15T06:04:36.712Z","extensionVersion":"v2.5.1"}
@chengcyber
chengcyber / CoolComponent.spec.js
Last active March 4, 2017 13:39
Mocha test js
// CoolComponent.spec.js
// includeJSX test children component
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import expect from 'expect';
import expectJSX from 'expect-jsx';
expect.extend(expectJSX);
const CoolComponent = ({greeting}) => (
{
repository(owner: "facebook", name: "mention-bot") {
object(expression: "master") {
... on Commit {
blame(path: "cookieJar.js") {
ranges {
startingLine
endingLine
age
commit {
# Autogenerated input type of AddComment
input AddCommentInput {
# A unique identifier for the client performing the mutation.
clientMutationId: String
# The Node ID of the subject to modify.
subjectId: ID!
# The contents of the comment.
body: String!