Skip to content

Instantly share code, notes, and snippets.

korzio

Block or report user

Report or block korzio

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
View getResponseSize.js
function getResponseSize(url) {
return fetch(url).then(response => {
const reader = response.body.getReader()
let total = 0
return reader.read().then(function processResult(result) {
if (result.done) return total
const value = result.value
total += value.length
console.log('Received chunk', value)
return reader.read().then(processResult)
View response.js
async function getResponseSizeAsync(url) {
const response = await fetch(url)
const reader = response.body.getReader()
let total = 0
while (true) {
const result = await reader.read()
if (result.done) {
return total
}
View slack.js
const { IncomingWebhook } = require('@slack/webhook')
const url = process.env.SLACK_WEBHOOK_URL
const webhook = new IncomingWebhook(url)
// Send the notification
(async () => {
await webhook.send({
text: 'I\'ve got news for you...',
})
})()
View index.js
#!/usr/bin/env node
const { description, name, version } = require('./package.json')
const options = process.argv.slice(2)
const VERSION_MESSAGE = `${name} ${version}`
const HELP_MESSAGE = `${VERSION_MESSAGE}
${description}
Usage:
--help Help documentation
View new project.txt
_ _ ____ _ _
| \ | | _____ __ | _ \ _ __ ___ (_) ___ ___| |_
| \| |/ _ \ \ /\ / / | |_) | '__/ _ \| |/ _ \/ __| __|
| |\ | __/\ V V / | __/| | | (_) | | __/ (__| |_
|_| \_|\___| \_/\_/ |_| |_| \___// |\___|\___|\__|
|__/
@korzio
korzio / async generators.js
Last active Jul 1, 2019
Based on impressions of Kyle Simpson's "JavaScript: The Recent Parts" workshop - https://frontendmasters.com/courses/js-recent-parts/ . The task is to demonstrate the ability of iterating async requests with asap strategy, where both all the requests are done, and the results are returned as soon as possible
View async generators.js
async function get(n) {
return new Promise(r => setTimeout(() => r(n), n * 100))
}
async function* asyncGenerator(arr) {
let anyResolve
arr.map(get).forEach(async request => {
const anyResult = await request
anyResolve(anyResult)
@korzio
korzio / CLI.md
Last active Jun 30, 2019
Educational Open Source CLI Project
View CLI.md

Educational Open Source CLI Project

Moved to Repository

Goal

Write a Command Line Interface application to create, edit, delete, and manage notes. Notes are structured in a user defined folders structure as a Git repo. Each note is saved with the git commit command. The tool is and easily extendable with plugins.

Technologies

View oclif add command.ts
npx oclif help
npx oclif command-help
npx oclif command add
my-oclif add
@korzio
korzio / JS Planet Alex Korzhikov
Created Jun 2, 2019
JS Planet Alex Korzhikov
View JS Planet Alex Korzhikov
_ ____ ____ _ _
| / ___| | _ \| | __ _ _ __ ___| |_
_ | \___ \ | |_) | |/ _` | '_ \ / _ \ __|
| |_| |___) | | __/| | (_| | | | | __/ |_
\___/|____/ |_| |_|\__,_|_| |_|\___|\__|
_ _ _ __ _ _ _
/ \ | | _____ __ | |/ /___ _ __ ___| |__ (_) | _______ __
/ _ \ | |/ _ \ \/ / | ' // _ \| '__|_ / '_ \| | |/ / _ \ \ / /
/ ___ \| | __/> < | . \ (_) | | / /| | | | | < (_) \ V /
/_/ \_\_|\___/_/\_\ |_|\_\___/|_| /___|_| |_|_|_|\_\___/ \_/
View commit.ts
import {Hook} from '@oclif/config'
import * as nodegit from 'nodegit'
import * as path from 'path'
const hook: Hook<'commit'> = async function ({id, file: fileName}) {
const directoryName = process.cwd()
const repo = await nodegit.Repository.open(path.resolve(directoryName, '.git'))
const index = await repo.refreshIndex()
await index.addByPath(fileName)
You can’t perform that action at this time.