Skip to content

Instantly share code, notes, and snippets.

View necccc's full-sized avatar

Szabolcs Szabolcsi-Toth necccc

View GitHub Profile
@necccc
necccc / RelatedPeople.jsx
Created October 19, 2019 07:31
Gists for "Next.js & Apollo GraphQL Performance Tuning: Subtree Pagination"
<RelatedPeople
id={ '' }
pageData={{
first,
offse,
total
}}
data={ [ {}, {} ] }
onLoadMore={ () => {} }
@necccc
necccc / Starships.jsx
Created October 20, 2019 13:53
Gists for Next.js & Apollo GraphQL Performance Tuning: Lists & pagination
// our GraphQL Query,
// get the name and ID of some Starships
export const getStarships = gql`
query getStarships {
starshipList {
items {
name
id
}
# cache this kind of resource for an hour
type Person@cacheControl(maxAge: 3600) {
id: ID!
name: String!
height: Int
bio: String
# cache the image field for a week
picture: String @cacheControl(maxAge: 10080)
@necccc
necccc / arguments_relationship-strict_mode.js
Created October 20, 2019 14:20
Gist for When arguments are mutable
// using strict mode
var fn3 = function (a) {
"use strict";
a = "foo"
console.log(arguments[0])
}
// arguments, and the arguments object no longer track each other
fn3(2) // 2
# deprecate a single version
npm deprecate [email protected] "this version is not supported any more, pelase update"
# deprecate everything below a version
# mind the double-qoutes around the version information!
npm deprecate my-module@"< 1.0.4" "critical bug fixed in 1.0.4, please update"
@necccc
necccc / StarshipList.jsx
Created October 20, 2019 20:14
Gist for "Next.js & Apollo GraphQL Performance Tuning: From Lists to Details"
// our GraphQL Query,
// get the name and ID of some Starships
export const getStarships = gql`
query getStarships {
starshipList {
items {
name
id
}
@necccc
necccc / no_ligature.css
Created October 21, 2019 06:51
Gist for This month I've learned - December
.no-ligature {
font-variant-ligatures: none;
}
const collect = []
collect.push(Uint8Array.of(1,3,5,7))
collect.push(Uint8Array.of(2,4,6,8))
// ... and so on
// concat them in the end
const gif = new Blob(collect, { type: 'image/gif' })
URL.createObjectURL(gif)
@necccc
necccc / builder_example.js
Created October 21, 2019 07:32
Gist for Transform your codebase using codemods
// create a function call that looks like
// "myfunc(someVar, 'bar')"
const callExpr = j.callExpression(
j.identifier(‘myFunc’),
[
j.indentifier('someVar')
j.literal('bar'),
]
)
@necccc
necccc / argument-placeholders.js
Created November 4, 2019 20:43
Gist for "Upcoming ESNext features - Part 1"
const add = function (a, b) { return a + b }
const addOne = add(1, ?) // will return a function, that needs one argument
addOne(2) // 3
addOne(6) // 7
[ 1,2,3 ].map(addOne) // [ 2,3,4 ]