This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const dns = require('dns') | |
const https = require('https') | |
const url = 'https://example.com' | |
const { hostname } = new URL(url) | |
const doLookup = () => new Promise(resolve => { | |
dns.lookup(hostname, resolve) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const dns = require('dns') | |
const https = require('https') | |
const url = 'https://example.com' | |
const { hostname } = new URL(url) | |
const doLookup = async () => new Promise(resolve => { | |
const start = new Date() | |
dns.lookup(hostname, () => { | |
console.log('dns.lookup', Date.now() - start) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { visit, print } from 'graphql' | |
import { gql } from 'graphql-tag' | |
// import the models from the generated code | |
import { getStudent, getTeacher, getClass } from '../graphql/queries' | |
const getModelSelectionSet = modelDoc => | |
modelDoc.definitions[0].selectionSet.selections[0].selectionSet | |
const attachModelDoc = (doc, fieldName, childDoc) => | |
visit(doc, { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Redis from 'ioredis' | |
const { | |
HOST: host, | |
PORT: port, | |
} = process.env | |
const redis = new Redis({ host, port }) | |
const subscribe = async (key, notifKey) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
import { flip } from 'svelte/animate' | |
import { dndzone, TRIGGERS } from 'svelte-dnd-action' | |
import { zip } from 'lodash' | |
export let ids | |
export let getItem | |
// distribute items over column count | |
let colCount = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const https = require('https') | |
const { PassThrough } = require('stream') | |
class WarcAgent extends https.Agent { | |
createConnection(...args) { | |
const socket = super.createConnection(...args) | |
const request = new PassThrough() | |
const response = new PassThrough() | |
// request stream via monkey-patching | |
const origWrite = socket.write |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { Transform } = require('stream') | |
const { createGzip } = require('zlib') | |
const fs = require('fs') | |
const testfile = fs.createWriteStream('test.gz') | |
const createShoutyStream = () => new Transform({ | |
construct(cb) { | |
this.data = '' | |
cb() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PROXY_URL=<your_proxy_url> | |
echo "HTTP" | |
time ( | |
curl --proxy $PROXY_URL -s -o /dev/null http://example.com | |
curl --proxy $PROXY_URL -s -o /dev/null http://example.com | |
curl --proxy $PROXY_URL -s -o /dev/null http://example.com | |
curl --proxy $PROXY_URL -s -o /dev/null http://example.com | |
curl --proxy $PROXY_URL -s -o /dev/null http://example.com | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { makeOperation } from '@urql/svelte' | |
import { authExchange } from '@urql/exchange-auth' | |
import { Auth } from 'aws-amplify' | |
import produce from 'immer' | |
import { set } from 'lodash' | |
const amplifyAuthExchange = authExchange({ | |
addAuthToOperation: ({ authState, operation }) => { | |
if (!authState?.token) { | |
return operation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { onMount } from 'svelte'; | |
function noop() { } | |
function run(fn) { | |
return fn(); | |
} | |
function blank_object() { | |
return Object.create(null); | |
} | |
function run_all(fns) { |