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 / index.html
Created July 1, 2011 01:14
Rotation of elements in PhoneGap using CSS transform and PhoneGap Compass API
<html>
<head>
<title>Compass Test</title>
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, target-densityDpi=device-dpi" />
<script type="text/javascript" src="phonegap.0.9.6.1.js"></script>
<script type="text/javascript">
var d = -45,
e = null,
w = null;
function win(h) {
@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 / directions.md
Last active August 23, 2019 13:36
putting together an lxc for appium on ubuntu

ubuntu lxc

NOTES:

  • p1 referred to below is simply the name given to the LXC. You can change this if you want, just remember to always refer to the same container name :P
  • Only for real devices: make sure that the vendor ID you enter into the android udev rules file matches the device you want to be visible
  1. first, set up vagrant VM to run on a "public network". My Vagrantfile's only network config is:

config.vm.network "public_network", :bridge => 'en0: Wi-Fi (AirPort)'

@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.