Skip to content

Instantly share code, notes, and snippets.

@elawad
elawad / task-def-deregister.sh
Last active March 13, 2022 22:12
Deregister ECS Task Definitions by family and revision range
#!/bin/bash
FAMILY=your-task-def-family-name
# Update ranges to deregister certain revisions.
for VER in {1..100}; do
# Sleep after 40 calls to reduce AWS ThrottlingException.
if (( $VER % 41 == 0 )); then
sleep 10
fi
@elawad
elawad / .sequelizerc.js
Last active March 8, 2023 13:42
Sequelize using ES Module imports
require('@babel/register')({
presets: [
['@babel/preset-env', { targets: { node: 'current' } }]
]
});
const path = require('path');
const DB_PATH = 'dist/db'; // use dist instead of src directory
module.exports = {
@elawad
elawad / format-size.js
Last active March 29, 2021 10:03
Format file size like macOS
function formatSize(size) {
const base = 1000; // 1000 or 1024
const kb = base ** 1;
const mb = base ** 2;
const gb = base ** 3;
let num;
num = (size / 1).toFixed(0);
if (num < base) return Number(num) + ' B';
@elawad
elawad / Auth.jsx
Last active February 27, 2020 16:20
RR4, Auth, Layouts, and SSR
render() {
const {
isAuthenticated,
location: { pathname },
route: { routes },
} = this.props;
const branch = matchRoutes(routes, pathname);
const Layout = branch[0].route.emptyLayout ? EmptyLayout : DefaultLayout;