Skip to content

Instantly share code, notes, and snippets.

View ersinakinci's full-sized avatar

Ersin Akinci ersinakinci

View GitHub Profile
@ersinakinci
ersinakinci / globalFetchingExchange.js
Last active February 9, 2022 23:08
urql exchange for monitoring global fetching status
/* A naively-implemented urql exchange for monitoring whether urql is fetching
* a query or a mutation on a global level.
*
* https://formidable.com/open-source/urql/docs/concepts/exchanges
* https://wonka.kitten.sh
* https://wonka.kitten.sh/api/operators#onpush
*
* Example usage:
*
* // If this number is greater than 0, an operation is in-flight and so urql is fetching
@ersinakinci
ersinakinci / webpack-tree-shaking-test-1-functions.csv
Last active May 11, 2020 20:51
Webpack tree shaking test (experiment 1: export, reexport, import): functions
Function # Exported from bar reexported from reexportBar imported by index Used in bar Used in reexportBar Used in index
1 ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
2 ✔️ ✔️ ✔️ ✔️ ✔️
3 ✔️ ✔️ ✔️ ✔️ ✔️
4 ✔️ ✔️ ✔️ ✔️
5 ✔️ ✔️ ✔️ ✔️ ✔️
6 ✔️ ✔️ ✔️ ✔️
7 ✔️ ✔️ ✔️ ✔️
8 ✔️ ✔️ ✔️
9 ✔️ ✔️ ✔️ ✔️
@ersinakinci
ersinakinci / webpack-tree-shaking-test-1-results.csv
Last active May 12, 2020 00:30
Webpack tree shaking test (experiment 1: export, reexport, import): results
Scenario index s/e reexportBar s/e bar s/e 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Baseline 🔵 🔵 🔵 ⚫️ ⚫️ ⚫️ ⚫️ ⚫️ ⚫️ ⚫️ ⚫️ ⚫️ ⚫️ ⚫️ ⚫️ ⚫️ ⚫️ ⚫️
sE 🔵 🔵 🔵 ⚫️ ⚫️ ⚫️ ⚫️ ⚫️ ⚫️ ⚫️ ⚫️ ⚫️ ⚫️ ⚫️ ⚫️ ⚫️ ⚫️ 🔵
uE 🔵 🔵 🔵 ⚫️ ⚫️ ⚫️ 🔵 ⚫️ ⚫️ ⚫️ ⚫️ 🔵 ⚫️ 🔵 🔵
uE + sE 🔵 🔵 🔵 ⚫️ ⚫️ ⚫️ 🔵 ⚫️ ⚫️ ⚫️ ⚫️ 🔵 ⚫️ 🔵 🔵
cM 🔵 🔵 🔵 ⚫️ ⚫️ ⚫️ 🔵 ⚫️ 🔵 🔵 ⚫️ 🔵 🔵 🔵 🔵
cM + uE 🔵 🔵 🔵 ⚫️ ⚫️ ⚫️ 🔵 ⚫️ 🔵 🔵 ⚫️ 🔵 🔵 🔵 🔵
cM + sE 🔵 🔵 🔵 ⚫️ ⚫️ ⚫️ 🔵 ⚫️ 🔵 🔵 ⚫️ 🔵 🔵 🔵 🔵
cM + uE + sE 🔵 🔵 🔵 ⚫️ ⚫️ ⚫️ 🔵 ⚫️ 🔵 🔵 ⚫️ 🔵 🔵 🔵 🔵
Production 🔵 🔵 🔵 ⚫️ ⚫️ ⚫️ 🔵 ⚫️ 🔵 🔵 ⚫️ 🔵 🔵 🔵 🔵
@ersinakinci
ersinakinci / webpack-tree-shaking-test_1-baseline-emit.js
Last active May 11, 2020 18:22
Webpack tree shaking test, example 1: baseline (emitted main.js)
/*!****************!*\
!*** ./bar.js ***!
\****************/
/*! exports provided: bar */function(e,t,n){"use strict";n.r(t),n.d(t,"bar",(function(){return o}));const o=()=>console.log("bar");console.log("bar side effect")},"./baz.js":
/*!****************!*\
!*** ./baz.js ***!
\****************/
/*! exports provided: baz */function(e,t,n){"use strict";n.r(t),n.d(t,"baz",(function(){return o}));const o=()=>console.log("baz");console.log("baz side effect")},"./foo.js":
/*!****************!*\
!*** ./foo.js ***!
@ersinakinci
ersinakinci / astToFaunaQuery.ts
Created March 30, 2020 18:02
AST to Fauna query with fragment spread and non-null support
import {
TypeInfo,
visit,
visitWithTypeInfo,
isLeafType,
isNonNullType,
GraphQLList
} from "graphql";
import { query as q } from "faunadb-fql-lib";
@ersinakinci
ersinakinci / cli-email-system.md
Last active March 9, 2020 01:31
Outline of a modern CLI-based email system

Modern CLI email system

Overview

Getting user-friendly email to work on the terminal is difficult. There's a lot of information out there, but a lot of it is ill-suited or overkill for the average user, who simply wants to check Gmail or some other web mail account in their terminal. This post is meant to be an opinionated overview of what you need to get such a system in place.

Modern CLI email is about synchronization

@ersinakinci
ersinakinci / nix-notes.md
Last active March 3, 2020 20:46
Notes and gotchas while using Nix

nix-env

Installing

  • If you install a package that has periods in the attribute path, you'll need to wrap the subpath on the command line using escaped double quotation marks. For example, packages generated by the node2nix tool can have NPM package versions affixed to the attribute, depending on how node2nix is set up. Version ^0.0.1-1 of redux-devtools-cli may be represented as nodeModules.redux-devtools-cli-^0.0.1-1, which on the command line would be installed like so: npm -f '<nixpkgs>' -iA "nodeModules.\"redux-devtools-cli-^0.0.1-1\"".

node2nix

Ways of installing Node packages

@ersinakinci
ersinakinci / relay_graphql_notes.md
Created January 28, 2020 00:39
Relay/GraphQL notes

Data flow

All data flows from queries

All data flows downward from queries, which are what fetch data from/push data to the server. Generally speaking, queries are only executed by QueryRenderer, although there are exceptions (e.g., pagination container queries). _Fragments are NEVER the original source of data from a server. If you see fragment ..., it MUST receive its data from elsewhere, most likely a QueryRenderer.

Data is passed to fragment containers from queries through props

Take the following example:

@ersinakinci
ersinakinci / tsconfig-primer.md
Last active February 17, 2020 12:49
tsconfig.json primer

tsconfig.json primer

Documentation progress

Fundamental

Language compatibility

  • compilerOptions.jsx
  • compilerOptions.lib
@ersinakinci
ersinakinci / electron-webpack-node-integration-false.md
Last active January 25, 2023 19:03
Making electron-webpack work with nodeIntegration: false

NOTE, April 18, 2020: I wrote this document in February 2019 when I was actively investigating Electron. I haven't used it since then and have largely forgotten what this was for or how electron-webpack works. I vaguely remember the problem, but that's it. It would appear based on the comments below that this document is still coming up in web searches but has become out of date and parts of it don't work. If anyone has specific fixes to my instructions, please leave them in the comments and I'll happily incorporate them.

Using electron-webpack without Node integration

Overview

The current version (as of 2019-02-02) of electron-webpack is set up with the assumption that your BrowserWindow instance has nodeIntegration: true. However, Electron is encouraging users to set nodeIntegration: false as a security precaution, and in the future BrowserWindows will have this setting set to false by default. Doing so now with electron-webpack throws an error because the index.html template has commonjs re