Skip to content

Instantly share code, notes, and snippets.

View Aposhian's full-sized avatar

Adam Aposhian Aposhian

View GitHub Profile
const dynamoose = require('dynamoose')
const AWS = require('aws-sdk')
const { v4: uuid } = require('uuid')
const credentials = new AWS.Credentials('akid', 'secret', 'session')
const ddb = new AWS.DynamoDB({
credentials,
region: 'us-east-1',
endpoint: 'http://localhost:8000'
})
@Aposhian
Aposhian / index.js
Created March 3, 2021 01:53
Autogenerated index.js
const path = require('path')
const fs = require('fs')
const files = fs.readdirSync(path.dirname('.'))
const toFunctionName = (str) => str.replace(
/([-_][a-z])/g,
(group) => group.toUpperCase()
.replace('-', '')
.replace('_', '')
@Aposhian
Aposhian / jest aws-sdk-mock.js
Created March 3, 2021 23:04
jest aws sdk mock
const mockFn = (mockResult) => jest.fn(() => ({
promise: () => Promise.resolve(mockResult)
}))
const implementation = {
method1: mockFn({ result1: '' }),
method2: mockFn({ result2: '' }),
...
}
@Aposhian
Aposhian / simulate-bad-connection.sh
Created March 11, 2021 13:57
Simulate a lossy network connection
#!/usr/bin/env bash
[ "$(id -u)" != "0" ] && echo "Please run as root" && exit 1
function usage {
echo "Usage:
./simulate_bad_connection.sh (-a | --address) <dest-ip-address>
[ -d | --delay ] <delay-in-ms>
[ -t | --timeout ] <timeout-seconds>
"
@Aposhian
Aposhian / aoe2de.sh
Created January 6, 2022 02:14
Age of Empires II: Definitive Edition Proton Trick
#!/usr/bin/env bash
set -ex
STEAM_DIR=/data/steam/steamapps
AOE2DE_DIR=$STEAM_DIR/compatdata/813780
AOE2DE_WIN_DIR=$AOE2DE_DIR/pfx/drive_c/windows
AOE2DE_WIN_SYS32_DIR=$AOE2DE_WIN_DIR/system32
AOE2DE_WIN_SYS64_DIR=$AOE2DE_WIN_DIR/syswow64
@Aposhian
Aposhian / Dockerfile
Last active January 11, 2022 23:00
Can't use event-triggered ReadyToTest
FROM ros:galactic
COPY setup.sh .
COPY launch.test.py .
RUN . /opt/ros/$ROS_DISTRO/setup.sh && python3 -m launch_testing.launch_test launch.test.py
@Aposhian
Aposhian / test.cpp
Created February 8, 2022 00:10
test of std::transform behavior when start and end are the same
#include <algorithm>
#include <vector>
#include <iostream>
int main() {
std::vector<int> a = { 0, 1, 2, 3 };
std::vector<int> b;
std::transform(
a.begin(), a.begin(),
@Aposhian
Aposhian / Dockerfile
Created April 6, 2022 20:58
Pythonfile
#syntax=docker/dockerfile:1.4
FROM ubuntu
RUN apt-get update && apt-get install -y python3
SHELL ["/usr/bin/python3", "-c"]
RUN <<EOF
import platform
my_os = platform.system()
if my_os.lower() == "linux":
print("oh yeah")
else:
@Aposhian
Aposhian / Makefile
Last active April 26, 2022 22:33
std::transform benchmarking
test:
g++ -std=c++17 -O3 main.cpp -ltbb -lbenchmark -lpthread -o benchmark
./benchmark
@Aposhian
Aposhian / capture-this.cpp
Created May 9, 2022 16:08
Implicit capture of class members when `this` is captured
#include <iostream>
class MyClass {
public:
void do_stuff() {
auto fn = [this]() {
do_more_stuff();
};
fn();
}