Skip to content

Instantly share code, notes, and snippets.

@thoroc
thoroc / README.md
Created October 9, 2024 18:32
Removel sophos AV from MacOS

Remove sophos keychain

sudo rm /Library/"Sophos Anti-Virus"/SophosSecure.keychain

Disable sophos

sudo defaults write /Library/Preferences/com.sophos.sav TamperProtectionEnabled -bool false
@thoroc
thoroc / put-event.json
Created October 7, 2024 16:50
Attempting to setup eventbridge rule to send logs to cloudwatch
[
{
"Source": "my.application",
"DetailType": "TestEvent",
"Detail": "{\"message\": \"Hello World\"}",
"EventBusName": "default"
},
{
"Source": "my.application",
"DetailType": "MyAppEvent",
@thoroc
thoroc / git-checkout-repo.sh
Created October 1, 2024 08:04
Git checkout repository, reproducing the path of the origin locally
#!/bin/bash
# put an alias in your .gitconfig to where the script lives: co-repo = ~/.bin/git-checkout-repo.sh
# don't forget to `chmod +x` it
# Input Git repository URL
REPO_URL="$1"
# Define the target base directory (where all projects should reside)
TARGET_BASE_DIR=~/Projects
@thoroc
thoroc / README.md
Last active April 16, 2024 10:14
Api Gateway with CDK (Python)

Api Gateway with CDK

source: https://www.sccbrasil.com/blog/aws/cdk-api.html

By Wolfgang Unger

Lets have a look how to create a API Gateway with CDK (Python) The first approach is using the RestApi Class and code the resources and methods. The second by using a Swagger/Open API file. Both APIs will use lambda integrations.

@thoroc
thoroc / appl.csv
Created February 25, 2024 20:13
just so I can call it and not host it directly.
date close
2007-04-23 93.24
2007-04-24 95.35
2007-04-25 98.84
2007-04-26 99.92
2007-04-29 99.8
2007-05-01 99.47
2007-05-02 100.39
2007-05-03 100.4
2007-05-04 100.81
@thoroc
thoroc / get_resolvers.sh
Created January 29, 2024 16:18
Example on how to fetch all the functions resolver for an GraphQL API on AWS and output them per template (dealing with VTL)
#!/bin/sh
# set the table list for "DrawTable" "GameTable" "PlayroundTable"
TABLE_NAMES="DrawTable GameTable PlayroundTable"
# API_ID="asdasdadajsdljalskdjalksdj"
# use the following command to get the list of functions
# FUNCTION_FILE=$(aws appsync list-functions --api-id "$API_ID")
FUNCTION_FILE="list_functions_full.json"
rm -rf resolvers
@thoroc
thoroc / inspect_object.ts
Created July 21, 2023 13:28
Demonstration of how wrangling ChatGPT for 3 hours gave code that compile ....
import * as util from 'util';
const url = 'https://bitbucket.org/example-org/example-repo';
let address = new URL(url);
console.log(address);
class BitbucketRepo extends URL {
public readonly organisation: string;
@thoroc
thoroc / merging_string_array.ts
Created July 21, 2023 10:50
Merging string[] in Typescript
interface MyOptions {
dirs: string[];
length?: number;
yaml?: boolean;
name?: string;
}
const options1: MyOptions = {
dirs: ['src', 'test'],
length: 88,
@thoroc
thoroc / click_debug.py
Created April 14, 2023 07:38
How to set the cli app to show debug logs with loguru
import click
from loguru import logger
@click.command()
@click.option(
"-d",
"--debug",
is_flag=True,
help="Enable debug mode. Prints debug messages to the console.",
)
@thoroc
thoroc / convert_from_aws.py
Created April 14, 2023 07:02
cloudformation template to terraform template
import sys
import json
from pathlib import Path
from collections import OrderedDict
from typing import Optional
import boto3
from botocore.exceptions import ClientError
import click
from loguru import logger
import oyaml as yaml