Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
.NOTPARALLEL : | |
# To make sure the Python virtual environment will be placed in the | |
# .venv directory: | |
# export PIPENV_VENV_IN_PROJECT=1 | |
# | |
# Get program help: | |
# make run | |
# | |
# Run the program: |
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
# Prompt example: ~/dir [repo-name] main () % | |
autoload -Uz vcs_info | |
zstyle ':vcs_info:git*' formats "[%r] %b (%a) %m%u%c " | |
precmd() { vcs_info } | |
setopt prompt_subst | |
PROMPT='${PWD/#$HOME/~} ${vcs_info_msg_0_}%# ' |
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 { S3Client } = require('@aws-sdk/client-s3'); | |
const { Upload } = require('@aws-sdk/lib-storage'); | |
const { PassThrough } = require('stream'); | |
/** | |
* A custom PassThrough stream for piping any sort of data in a | |
* backpressure-friendly way using Promises. | |
* | |
* Derives from PassThrough instead of Readble; otherwise, piping to | |
* files etc. won't work; for example, push(null) won't cause finished |
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
/** | |
* Custom ReadableStream stream for piping data in a backpressure-friendly way using Promises | |
* | |
* @see {@link https://terrislinenbach.medium.com/obeying-back-pressure-in-javascript-streams-read-stream-pipe-edition-ccd6203596bf|How ReadStream responds to back pressure} | |
* | |
* Derives from PassThrough instead of ReadbleStream; otherwise, piping to files etc. won't | |
* work -- for example, push(null) won't fire 'finished' events. | |
* | |
* Usage: | |
* - Call push(obj) to write obj to the stream |
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
#! /bin/sh | |
# Complex string manipulation in Bash example | |
# | |
# Transforms a string in the form of: "archives/A/B C", to: A/B/B C | |
line='"A/B C",' | |
# Remove starting " | |
line="${line#\"}" |
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
// See https://stackoverflow.com/questions/1250079/how-to-escape-single-quotes-within-single-quoted-strings | |
const zipPath = "fo''o.zip"; | |
const escapedZipPath = zipPath.replace(/'/g, "'\\''"); | |
const cmd = `/usr/bin/unzip '${escapedZipPath}' > /dev/null 2> /dev/null`; |
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
// Removes all /* C-style comments */ from a string | |
// Credit: | |
// https://blog.ostermiller.org/finding-comments-in-source-code-using-regular-expressions/ | |
// However this fixes the input string /* comment one */ blah /* comment two */ by using nongreedy match | |
// This intentionally doesn't work with //-style comments because it was written for MySQL comments only | |
'some string'.replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*?\*+\//g, ''); |
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
#!/bin/sh | |
# Purpose | |
# | |
# This is a reverse truncation script intended for but not limited to log | |
# files. The oldest log entries are discarded. | |
# | |
# This script operates on bytes only -- not lines or even characters. It | |
# alters the sizes of specified files in place efficiently, but with a heavy | |
# hand. It removes the beginning bytes from a file until it is roughly the |
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 humanizeDuration = require('humanize-duration'); | |
const Loggers = require('@goodware/log'); | |
const { PassThrough } = require('stream'); | |
const { ulid } = require('ulidx'); | |
/** | |
* See https://github.com/expressjs/body-parser for more options | |
*/ | |
const jsonParser = require('express').json({ limit: '10mb' }); |
NewerOlder