Skip to content

Instantly share code, notes, and snippets.

@filmaj
filmaj / documentclientqueryreadable.js
Last active April 6, 2024 03:20
readable dynamodb query stream using aws-lite
const { Readable } = require('node:stream');
const DocumentSource = require('./documentsource');
module.exports = class DocumentClientQueryReadable extends Readable {
constructor (client, params) {
super({ objectMode: true });
this.source = new DocumentSource(client, params);
this.source.on('data', this.onData.bind(this));
this.source.on('end', this.onEnd.bind(this));
}
@filmaj
filmaj / s3-cache.js
Last active December 29, 2023 17:33
arc.codes s3 download/upload utility in node with streams
const arc = require('@architect/functions');
const { GetObjectCommand, S3Client } = require('@aws-sdk/client-s3');
const { Upload } = require('@aws-sdk/lib-storage');
const client = new S3Client({});
const CONSTANTS = require('@architect/shared/constants');
const { timer } = require('@architect/shared/utils');
const jsonlines = require('@jsonlines/core')
const stream = require('stream');
/*
@filmaj
filmaj / definition.test.ts
Last active November 10, 2022 19:07
TypeScript ftw
// Some user-defined parameters based on primitive types
type BaseParamDefinition<N, T> = { type: N; default: T };
type BooleanParamDefinition = BaseParamDefinition<"boolean", boolean>;
type StringParamDefinition = BaseParamDefinition<"string", string>;
type NumberParamDefinition = BaseParamDefinition<"number",number>;
// A more complex parameter type: an object, with inputs, and an array that specifies which of the inputs are required.
type ObjectParamDefinition<
Inputs extends ParameterSetDefinition<PrimitiveParameterDefinition>,
RequiredInputs extends RequiredProperties<Inputs>,
> = {
@filmaj
filmaj / package.json
Created September 8, 2021 13:47
axios bug repro case v0.21.1 vs. v0.21.2
{
"name": "axios-repro",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "DEBUG=nock.scope* mocha test.js"
},
"keywords": [],
"author": "",
@filmaj
filmaj / app.js
Created August 30, 2021 17:28
Simple bolt-js Slack app with a view
const { App } = require('@slack/bolt');
// Initializes your app with your bot token and signing secret
const app = new App({
token: process.env.SLACK_BOT_TOKEN,
signingSecret: process.env.SLACK_SIGNING_SECRET,
socketMode: true,
appToken: process.env.SLACK_APP_TOKEN
});
// Listens to incoming messages that contain "hello"
@filmaj
filmaj / customqueue.js
Created July 7, 2021 00:46
arc macro for customized queue
const queue = 'MyDopeassQueue';
const dlq = `${queue}DLQ`;
module.exports = function queueCustomizer (arc, cloudformation) {
cloudformation.Resources[queue] = {
Type: 'AWS::SQS::Queue',
DependsOn: dlq,
Properties: {
MessageRetentionPeriod: 1209600, // max (14 days)
ReceiveMessageWaitTimeSeconds: 20, // enable long polling when asking for messages
@filmaj
filmaj / base_route_munger.js
Last active November 25, 2018 21:49
arc.codes single page app bui
let fs = require('fs');
const INDEX_HTML = 'public/index.html';
const INDEX_ROUTE = 'src/http/get-index/index.js';
let html = fs.readFileSync(INDEX_HTML).toString();
let route = fs.readFileSync(INDEX_ROUTE).toString();
route = route.replace(/`.*`/, '`' + html + '`'); // replace everything between two backticks with index.html. that's my sophisticated templating engine!
console.log('\nOverwriting index route to return new index.html...');
fs.writeFileSync(INDEX_ROUTE, route, 'utf-8');
var app = {
// Application Constructor
initialize: function() {
document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
},
// deviceready Event Handler
//
// Bind any cordova events here. Common events are:
// 'pause', 'resume', etc.
@filmaj
filmaj / tox-pr.log
Created July 31, 2017 22:13
tox output from running tests on idlharness-old-js PR, latest (SHA 944372b1f2)
➔ tox
python installed: EasyProcess==0.2.3,html5lib==0.999999999,py==1.4.34,pytest==3.1.3,PyVirtualDisplay==0.2.1,selenium==3.4.3,six==1.10.0,webencodings==0.5.1
python runtests: PYTHONHASHSEED='1711188449'
python runtests: commands[0] | pytest -vv tests
===================================================================== test session starts =====================================================================
platform darwin -- Python 2.7.13, pytest-3.1.3, py-1.4.34, pluggy-0.4.0 -- /Users/maj/src/web-platform-tests/resources/test/.tox/python/bin/python2.7
cachedir: .cache
rootdir: /Users/maj/src/web-platform-tests/resources/test, inifile:
collected 36 items
@filmaj
filmaj / tox-pr-minus-one.log
Created July 31, 2017 22:10
tox output from running tests on idlharness-old-js PR, NOT latest (SHA 8615bfbe92)
➔ tox
python installed: EasyProcess==0.2.3,html5lib==0.999999999,py==1.4.34,pytest==3.1.3,PyVirtualDisplay==0.2.1,selenium==3.4.3,six==1.10.0,webencodings==0.5.1
python runtests: PYTHONHASHSEED='1297519254'
python runtests: commands[0] | pytest -vv tests
===================================================================== test session starts =====================================================================
platform darwin -- Python 2.7.13, pytest-3.1.3, py-1.4.34, pluggy-0.4.0 -- /Users/maj/src/web-platform-tests/resources/test/.tox/python/bin/python2.7
cachedir: .cache
rootdir: /Users/maj/src/web-platform-tests/resources/test, inifile:
collected 36 items