Skip to content

Instantly share code, notes, and snippets.

@gpynes
gpynes / async-mappers.ts
Created November 7, 2022 15:06
TS async mapping utilities for parallel and sequential processing of arrays
export const mapParallel: IAsyncMapper = async (items, mapper) =>
Promise.all(items.map(mapper))
export const mapSequentially: IAsyncMapper = async (items, mapper) => {
type U = Awaited<ReturnType<typeof mapper>>
const results: U[] = []
for (const [idx, item] of Object.entries(items)) {
const result = await mapper(item, Number(idx))
results.push(result)
}
@gpynes
gpynes / cfg-install.sh
Last active September 20, 2020 05:51
Sets up cfg dir in a fresh comp
git clone --bare https://gitlab.com/gpynes/cfg.git $HOME/.cfg
function cfg {
/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME $@
}
mkdir -p .config-backup
cfg checkout
if [ $? = 0 ]; then
echo "Checked out config.";
else
@gpynes
gpynes / karabiner.json
Last active November 9, 2022 21:54
Home row arrow keys json setup
{
"global": {
"check_for_updates_on_startup": true,
"show_in_menu_bar": true,
"show_profile_name_in_menu_bar": false
},
"profiles": [
{
"complex_modifications": {
"parameters": {
const { createServer } = require('http')
const port = process.env.PORT || 3000
const httpServerRequestHandler = (request, response) => {
// Logs the method and url of the incoming request
console.log(request.method, '=>', request.url)
// Writes 'Hello World' into our response stream
response.write('Hello World')
// Sends the response back to the client
response.end()