Skip to content

Instantly share code, notes, and snippets.

View ColeMurray's full-sized avatar

Cole Murray ColeMurray

View GitHub Profile
import json
import logging
import csv
from typing import List, Dict, Any, Optional
from pydantic import BaseModel, create_model, Field, validator, field_validator
from openai import OpenAI
import time
# Set up logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
@ColeMurray
ColeMurray / snowflake-overview.md
Created June 25, 2024 06:40
Azure Snowflake DBT

Complete Tutorial: Azure, Snowflake, DBT, and Python with Medallion Architecture

Table of Contents

  1. Introduction
  2. Architecture Overview
  3. Setting Up the Environment 3.1. Azure Setup 3.2. Snowflake Setup 3.3. DBT Setup 3.4. Python Environment Setup
#!/bin/bash
# Update and upgrade Homebrew
echo "Updating Homebrew..."
brew update
brew upgrade
# Install nvm (Node Version Manager)
echo "Installing nvm..."
# settings we’re about to change
osascript -e 'tell application "System Preferences" to quit'
# Ask for the administrator password upfront
sudo -v
# Keep-alive: update existing `sudo` time stamp until `.macos` has finished
while true; do
sudo -n true
sleep 60
kill -0 "$$" || exit
@ColeMurray
ColeMurray / gist:6f615e105aac4d93650c7089b16fc279
Created November 12, 2023 00:29
basic google search custom engine
import json
import sys
from article_agent.config import my_api_key, my_cse_id
from googleapiclient.discovery import build
def get_search_results(search_term: str, num_search_results: int = 10) -> json:
"""Perform a Google search using Custom Search API"""
# Build request
@ColeMurray
ColeMurray / nextjs-amplify-stack.ts
Created October 13, 2023 19:04
Next.js Amplify CDK stack
import {App, AutoBranchCreation} from '@aws-cdk/aws-amplify-alpha';
import {CfnOutput, SecretValue, Stack, StackProps} from 'aws-cdk-lib';
import {BuildSpec} from 'aws-cdk-lib/aws-codebuild';
import {Construct} from 'constructs';
import {ManagedPolicy, Role, ServicePrincipal} from 'aws-cdk-lib/aws-iam';
import {GitHubSourceCodeProvider} from '@aws-cdk/aws-amplify-alpha/lib/source-code-providers';
import {environmentVariables} from './environmentVariables';
import {CfnApp, CfnBranch} from "aws-cdk-lib/aws-amplify";
import {configuration} from "./config";
@ColeMurray
ColeMurray / lambdaServer.ts
Created August 13, 2023 04:11
source/lambdaServer.ts for starting serverless express
import serverlessExpress from '@vendia/serverless-express';
import {app} from './app';
let serverlessExpressInstance: any;
async function setup (event: any, context: any) {
serverlessExpressInstance = serverlessExpress({ app })
return serverlessExpressInstance(event, context)
}
@ColeMurray
ColeMurray / app.ts
Created August 13, 2023 04:10
source/app.ts from serverless express
import express from "express";
import cors from "cors";
import apiRoutes from "./api";
import {errorResponder} from "./middleware/errorResponder";
export const app = express();
app.use(cors({origin: '*'}));
app.use(express.json());
app.use(express.urlencoded({extended: true}))
@ColeMurray
ColeMurray / stage.ts
Created August 13, 2023 03:45
Deployment stack for serverless express cdk project
import {Stage, StageProps} from "aws-cdk-lib";
import {Construct} from "constructs";
import {DeploymentStack} from "./stack";
interface BackendServiceStageProps extends StageProps {
envVars?: Record<string, string>,
}
export class BackendServiceStage extends Stage {
@ColeMurray
ColeMurray / stack.ts
Created August 13, 2023 03:43
Deployment stack for serverless-express
import {Stack, StackProps} from "aws-cdk-lib";
import {Construct} from "constructs";
import {ApprovedNodeLambda} from "./constructs/approvedNodeLambdaConstruct";
import {Cors, LambdaIntegration, RestApi} from "aws-cdk-lib/aws-apigateway";
export interface DeploymentStackProps extends StackProps {
envVars?: Record<string, string>,
}
export class DeploymentStack extends Stack {