Skip to content

Instantly share code, notes, and snippets.

View maatthc's full-sized avatar

Alexandre Andrade maatthc

  • MaaT Tech
  • Melbourne
View GitHub Profile
@maatthc
maatthc / Glue_Spark_job_example.yml
Last active February 10, 2022 18:02
Cloud Formation example for Glue Spark Job with metrics and scheduler
AWSTemplateFormatVersion: '2010-09-09'
Description: Cloud Formation example for Glue Spark Job with metrics and scheduler
Parameters:
ArtifactBucket:
Description: A global deployable artefact bucket
Type: String
Default: artefacts
ServiceName:
Description: Service Name that owns the stack when created
@maatthc
maatthc / karabiner_Mac_Intel.json
Last active February 3, 2022 00:49
Keyboard Ajazz K680T configuration via Karabiner-Elements on MacOS
{
"global": {
"check_for_updates_on_startup": true,
"show_in_menu_bar": true,
"show_profile_name_in_menu_bar": false
},
"profiles": [
{
"complex_modifications": {
"parameters": {
@maatthc
maatthc / access-gmail.ts
Last active July 19, 2021 08:46
How to use the Gmail API - Firstly enable the Gmail API on your account: https://developers.google.com/gmail/api/quickstart/nodejs
/* eslint-disable camelcase */
import { Gmail, gmail_v1, GaxiosResponse } from './gmail-client'
const SEARCH_PATTERN = 'My subject is ..'
const init = async () => {
const client = new Gmail()
console.log('Authenticating...')
await client.authorize()
console.log(`Searching for emails that contains ${SEARCH_PATTERN}..`)
@maatthc
maatthc / sleep.ts
Created July 17, 2021 09:19
Sleep (or wait) function in TypeScript (^4.3.5)
function sleep(ms: number) {
return new Promise(resolve => setTimeout(resolve, ms, ''))
}
@maatthc
maatthc / br.com.maat.vpn.plist
Last active October 29, 2020 14:00
This script runs upon login: Big IP Edge Client on Mac requires only part of McAfee to be running and jamfAgent
<!-- On line 16, replace 'MY_USERNAME' by your own username -->
<!-- Save as ~/Library/LaunchAgents/br.com.maat.vpn.plist -->
<!-- After creating both files, test it running: -->
<!-- $ launchctl load ~/Library/LaunchAgents/br.com.maat.vpn.plist -->
<!-- $ launchctl start br.com.maat.vpn -->
<!-- Check for error using: tail -f /var/log/system.log -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
@maatthc
maatthc / lauch.json
Last active October 1, 2020 10:35
Configuration files for Debugging TypeScript Serverless application using Visual Studio Code
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "pwa-node",
"request": "launch",
@maatthc
maatthc / aws-mock.ts
Created July 24, 2020 06:45
How to easily mock multiple AWS services using Jest - JavaScript
jest.mock('aws-sdk', () => {
return {
SSM: jest.fn(() => ({
getParameter: jest.fn(() => ({
promise: jest.fn().mockResolvedValue({ Parameter: { Value: 'SECRET-KEY' } }),
})),
})),
SQS: jest.fn(() => ({})),
S3: jest.fn(() => ({})),
SNS: jest.fn(() => ({})),
@maatthc
maatthc / service.spec.js
Last active July 16, 2020 06:13
(JavaScript) Jest test example use of toHaveBeenCalledTimes, objectContaining and arrayContaining in AWS Lambda
describe('Run method', () => {
const event: CloudWatchLogsEvent = {
awslogs: {
data: '',
},
}
it('should confirm shipments where emitted', async () => {
expect.assertions(2)
await service.run(event)
expect(sendBatchJSONMessages).toHaveBeenCalledTimes(1)
@maatthc
maatthc / OrderDynamics.ts
Last active July 15, 2020 06:12
OrderDynamics Helper Class - WIP
import { soap } from "strong-soap"
abstract class OrderDynamicsClient {
protected isAuthenticated: Boolean = false
protected soapClient: any
protected url: any
abstract authenticate(): Promise<void>
createClient(options: any) {
@maatthc
maatthc / build-linux-lambda.sh
Created June 25, 2020 10:44
Builds AWS Lambda packages with native Linux dependencies when using MacOs
#!/bin/sh
DOCKER_IMAGE=node:12.18.0
docker kill lamda-builder 2>/dev/null
docker rm lamda-builder 2>/dev/null
rm -rf build && rm -rf dist
mkdir -p build && mkdir -p ../dist
cp -r index.js package.json yarn.lock src deps build 2>/dev/null || :