Skip to content

Instantly share code, notes, and snippets.

:shipit:

Jane Manchun Wong wongmjane

:shipit:
Block or report user

Report or block wongmjane

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@shrugs
shrugs / README.md
Created Oct 21, 2019
apollo + next
View README.md

these are the relevant files from my next + apollo + prisma setup. the prisma bit isn't relevant and can just be removed from the context. likewise my resolvers + typedefs setup is hyper specific and there are infinitely many way to do this (lol javascript)

the only relevant bit that might be missing is the handler path that has to match your next.js route

@mfellner
mfellner / graphql.ts
Created Jul 8, 2019
Using Apollo Server in Next.js 9 with API route in pages/api/graphql.ts
View graphql.ts
import { ApolloServer, gql } from 'apollo-server-micro';
const typeDefs = gql`
type Query {
sayHello: String
}
`;
const resolvers = {
Query: {
@gaearon
gaearon / uselayouteffect-ssr.md
Last active Dec 6, 2019
useLayoutEffect and server rendering
View uselayouteffect-ssr.md

If you use server rendering, keep in mind that neither useLayoutEffect nor useEffect can run until the JavaScript is downloaded.

You might see a warning if you try to useLayoutEffect on the server. Here's two common ways to fix it.

Option 1: Convert to useEffect

If this effect isn't important for first render (i.e. if the UI still looks valid before it runs), then useEffect instead.

function MyComponent() {
View for-snook.md

https://twitter.com/snookca/status/1073299331262889984?s=21

‪“‬In what way is JS any more maintainable than CSS? How does writing CSS in JS make it any more maintainable?”

‪Happy to chat about this. There’s an obvious disclaimer that there’s a cost to css-in-js solutions, but that cost is paid specifically for the benefits it brings; as such it’s useful for some usecases, and not meant as a replacement for all workflows. ‬

‪(These conversations always get heated on twitter, so please believe that I’m here to converse, not to convince. In return, I promise to listen to you too and change my opinions; I’ve had mad respect for you for years and would consider your feedback a gift. Also, some of the stuff I’m writing might seem obvious to you; I’m not trying to tell you if all people of some of the details, but it might be useful to someone else who bumps into this who doesn’t have context)‬

So the big deal about css-in-js (cij) is selectors.

@necolas
necolas / Composite-Link.js
Created Sep 19, 2018
Next.js links with React Native for Web
View Composite-Link.js
@developit
developit / *valoo.md
Last active Nov 19, 2019
🐻 Valoo: just the bare necessities of state management. 150b / 120b. https://npm.im/valoo
View *valoo.md

🐻 valoo

just the bare necessities of state management.

Usage

Hotlink it from https://unpkg.com/valoo.

See Interactive Codepen Demo.

@sebmarkbage
sebmarkbage / The Rules.md
Last active Nov 20, 2019
The Rules of React
View The Rules.md

The Rules of React

All libraries have subtle rules that you have to follow for them to work well. Often these are implied and undocumented rules that you have to learn as you go. This is an attempt to document the rules of React renders. Ideally a type system could enforce it.

What Functions Are "Pure"?

A number of methods in React are assumed to be "pure".

On classes that's the constructor, getDerivedStateFromProps, shouldComponentUpdate and render.

@necolas
necolas / Hoverable.js
Last active Nov 4, 2019
Hover styles in React Native for Web
View Hoverable.js
import createHoverMonitor from './createHoverMonitor';
import { element, func, oneOfType } from 'prop-types';
import React, { Component } from 'react';
const hover = createHoverMonitor();
/**
* Use:
* <Hoverable>
* {(hover) => <View style={hover && styles.hovered} />}
@smitshilu
smitshilu / Tensorflow_Build_GPU.md
Last active Jul 24, 2019
Tensorflow 1.4 Mac OS High Sierra 10.13 GPU Support
View Tensorflow_Build_GPU.md

Tensorflow

System information

  • OS - High Sierra 10.13
  • Tensorflow - 1.4
  • Xcode command line tools - 8.2 (Download from here: Xcode - Support - Apple Developer & Switch to different clang version: sudo xcode-select --switch/Library/Developer/CommandLineTools & check version: clang -v)
  • Cmake - 3.7
  • Bazel - 0.7.0
@cecilemuller
cecilemuller / letsencrypt_2019.md
Last active Dec 8, 2019
How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SSL rating)
View letsencrypt_2019.md

How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SLL rating)


Virtual hosts

Let's say you want to host domains first.com and second.com.

Create folders for their files:

You can’t perform that action at this time.