Skip to content

Instantly share code, notes, and snippets.

View carbonrobot's full-sized avatar

Charlie Brown carbonrobot

View GitHub Profile
@carbonrobot
carbonrobot / lint.md
Created January 10, 2024 14:42
Victory v36.x Wireit Build Flow for ESLint
$ pnpm lint

/package.json | scripts: { "lint": "wireit" }
  /package.json | wireit: "lint" => ["lint:root", "lint:pkgs"]
    /package.json | scripts: { "lint:root": "wireit" }
      /package.json | wireit: "lint:root" => "nps lint:base (files)"
        /package-scripts.js | scripts: "lint:base" => "eslint (options)"
    /package.json | scripts: { "lint:pkgs": "wireit" }
 /package.json | wireit: "lint:pkgs" => ["packages/*] => "lint"
@carbonrobot
carbonrobot / merp.sh
Created October 27, 2022 19:59
Convert Github Actions Set Output to new format
#! /bin/bash
for i in $(grep -rv '^#' | grep '::set-output name=' | cut -d':' -f1); do
sed -i '' -e 's/::set-output name=\([^:]*\)::\(.*\)/\1=\2 >> ${GITHUB_OUTPUT}/' "${i}"
done
@carbonrobot
carbonrobot / remote.sh
Created December 5, 2019 16:04
Push a branch to a different remote git branch
git push origin local-name:remote-name
@carbonrobot
carbonrobot / export.sh
Last active August 9, 2019 15:51
Exports Terraform outputs into an environment file that can be sourced into shell
# Exports Terraform outputs into an environment file that can be sourced into shell
# Supports Terraform 0.12+ (also works with Terragrunt 19+)
#
# It can be useful to export tf outputs into a .env file for use with serverless, jenkins, and node
# to use with tools that directly support dotenv, remove the "export " from the prefix
#
# Steps
# 1. Gets the terraform output
# 2. Add quotes to the right hand side of equals
# 3. Remove spaces around equal signs
@carbonrobot
carbonrobot / options.md
Last active February 27, 2019 15:33
Icon options

Option 1

Pregenerate the exports in the index.js using a script

// ionic/index.js

import SvgIosAdd from './IosAdd';
import SvgIosAddCircle from './IosAddCircle';
@carbonrobot
carbonrobot / load.js
Last active January 8, 2019 22:02
Recursively get files from an s3 bucket with nodejs aws-sdk
const AWS = require('aws-sdk');
const s3 = new AWS.S3();
function getObjects({ bucket, marker, prev }, callback) {
var params = {
Bucket: bucket,
Marker: marker,
}
return s3.listObjects(params).promise().then(data => {
@carbonrobot
carbonrobot / promise.js
Created March 29, 2018 14:38
Sequential Promises
function go(id) {
return new Promise((resolve, reject) => {
console.log('promise entered', id);
const rnd = Math.random() * 500;
setTimeout(() => {
resolve('resolved');
}, rnd);
});
}
@carbonrobot
carbonrobot / csvStreamParser.js
Created March 12, 2018 13:49
CSV Parser with Schema Validation
const csv = require('fast-csv');
const HeaderValidationError = require('./headerValidationError');
/**
* TODO: missing features
* Check for missing condtl data
* Check for missing exclusive condtl data
* Check for invalid characters in headers
* Test for non-joi validation
* Joi helper should export custom joi instance
@carbonrobot
carbonrobot / 1_test.js
Last active February 28, 2018 23:06
CSVFileStreamParser
const marky = require('marky');
const fs = require('fs');
const Joi = require('joi');
const CSVStreamParser = require('./csvStreamParser.js');
const FILENAME = './files/single.csv';
const input = fs.createReadStream(FILENAME);
const CENSUS_ATTR_MAP = {
lastname: 'lastName',
@carbonrobot
carbonrobot / csv-parse.js
Last active February 28, 2018 17:05
Comparing performance of CSV parser libs on very large files
const chalk = require('chalk');
const marky = require('marky');
const parse = require('csv-parse');
const fs = require('fs');
const es = require('event-stream');
const csv = require('fast-csv');
// -------------------------
// Using raw event-stream
// This is the reference throughput