Skip to content

Instantly share code, notes, and snippets.

View arabold's full-sized avatar
🦀
Making things. Breaking things.

Andre Rabold arabold

🦀
Making things. Breaking things.
View GitHub Profile
@arabold
arabold / action.yml
Created March 10, 2024 13:12
GitHub Action: Increment Version
name: 🔄 Increment Version
description: Increment the repository version number
inputs:
namespace:
description: "Use to create a named sub-version. This value will be prepended to tags created for this version."
required: false
channel:
description: "Denote the channel or pre-release version, i.e. alpha, beta, rc, etc."
required: false
@arabold
arabold / fix-glue-table-schema.py
Created August 24, 2023 20:35
Fix Glue Table Schema
import boto3
boto3.setup_default_session(region_name="eu-central-1")
def make_partitions_inherit_datatypes_of_table(database_name, table_name):
glue_client = boto3.client("glue")
# Get the data types of the base table
table_response = glue_client.get_table(
DatabaseName=database_name,
@arabold
arabold / PythonOfflineFix.js
Created October 6, 2022 15:15
Run Serverless Offline and Serverless Python Requirements together
#!/usr/bin/env node
"use strict";
const path = require("path");
const fs = require("fs");
/**
* Custom Serverless plugin to fix an issue with Serverless Offline not resolving the requirements
* path of the Serverless Python Requirements plugin.
@arabold
arabold / serverless.yml
Created August 17, 2022 15:36
Serverless Cognito Setup
service: auth
frameworkVersion: "3"
provider:
name: aws
runtime: nodejs16.x
stage: ${opt:stage, 'dev'}
region: ${opt:region, 'us-east-1'}
timeout: 300
@arabold
arabold / useDataStoreQuery.tsx
Last active February 23, 2023 18:07
Simplify querying the Amplify DataStore using React hooks
import {
DataStore,
PersistentModel,
PersistentModelConstructor,
ProducerModelPredicate,
SortPredicate,
ProducerPaginationInput
} from '@aws-amplify/datastore'
import { useCallback, useEffect, useState } from 'react'

Add the following scripts to package.json:

    "clean": "npm run clean:git && npm run clean:npm && npm run clean:tmp && npm run clean:android && npm run clean:ios",
    "clean:android": "cd android && rimraf .gradle build && (./gradlew clean --continue || true) && cd ..",
    "clean:git": "git clean -fdX",
    "clean:ios": "cd ios && xcodebuild clean -quiet && rimraf Pods && pod cache clean && pod deintegrate && cd ..",
    "clean:npm": "rimraf node_modules && npm cache clean --force",
    "clean:tmp": "watchman watch-del-all && rimraf '$TMPDIR/react-native-packager-cache-*' && rm -fr '$TMPDIR/metro-cache' && rm -fr '$TMPDIR/haste-map-*'"
export type SemaphoreFunction = (done: () => void) => void;
/**
* Based on https://www.derpturkey.com/simple-semaphore-in-nodejs/
*/
export default class Semaphore {
readonly max: number;
private _fns: Array<SemaphoreFunction>;
private _active: number;
export function createSimpleLogger(asJson: boolean): LogHandlerFunc {
return function log(logEntry) {
console.log(asJson ? JSON.stringify(logEntry) : logEntry);
};
}
export function createSimpleLogger(): LogHandlerFunc {
return function log(logEntry) {
console.log(logEntry);
};
}
/** Metadata shared between all instances of the Logger */
private static _globalMetaData?: Payload;
static setGlobalMeta(meta: Payload): void {
Logger._globalMetaData = { ...meta };
}