Skip to content

Instantly share code, notes, and snippets.

View tomshaw's full-sized avatar
🎯
Focusing

Tom Shaw tomshaw

🎯
Focusing
View GitHub Profile
@tomshaw
tomshaw / Microsoft.PowerShell_profile.ps1
Created April 3, 2025 01:15
PSReadLine PowerShell configuration with well-organized comments and grouped settings.
# Import PSReadLine for enhanced command-line experience
Import-Module PSReadLine
# Prediction settings
Set-PSReadLineOption -PredictionSource HistoryAndPlugin
Set-PSReadLineOption -PredictionViewStyle ListView
# Alternate prediction style:
# Set-PSReadLineOption -PredictionViewStyle InlineView
# Optional bell settings (uncomment to enable audio feedback)
@tomshaw
tomshaw / models.py
Created February 9, 2025 02:37
List OpenAI available models.
from openai import OpenAI
client = OpenAI()
models = client.models.list()
print([m.id for m in models.data])
@tomshaw
tomshaw / budget_data.py
Created February 8, 2025 21:02
U.S. federal government spending
budget_data = [
{
"Spending Category": "Social Security",
"FY2019 Outlays": "1.044T",
"FY2019 Outlays (2024 $)": "1.253T",
"FY2024 Outlays": "1.461T",
"Nominal Increase": "+$417B (40.0%)",
"Real Increase": "+$208B (16.6%)",
"2019 Budget in 2024 $ (Adjusted for Income Increase x1.11)": "1.391T",
"Change Beyond Income Increase": "+$70B (5.0%)"
@tomshaw
tomshaw / proposal.py
Created January 27, 2025 06:20
Generate a Business Proposal Word Document Using LangChain and Python-Docx
from langchain.prompts import PromptTemplate
from langchain_groq import ChatGroq
from langchain_ollama import ChatOllama
from docx import Document
# Step 1: Define the Prompt Template
prompt = PromptTemplate(
input_variables=["purpose"],
template="Write an introduction for a {purpose}. Keep it professional and concise. Include a header and footer with contact information, and a call to action.",
)
@tomshaw
tomshaw / countries.py
Created January 11, 2025 15:05
Ollama structured output data generation example.
from ollama import chat
from pydantic import BaseModel
import pandas as pd
import argparse
import logging
# Set up logging
logging.basicConfig(level=logging.INFO)
# Initialize an empty DataFrame
@tomshaw
tomshaw / Microsoft.PowerShell_profile.ps1
Created February 26, 2024 23:39
PowerShell Laravel Artisan Alias
# Laravel Artisan Alias
function artisan {
param (
[string]$Command
)
php artisan $Command
}
@tomshaw
tomshaw / Microsoft.Powershell_profile.ps1
Last active January 6, 2023 07:30
Windows Terminal Setup
# PowerShell 7.3.1 Profile
# Posh Git
Import-Module posh-git
$omp_config = "atomic" # Themes atomic, takuya, material, jandedobbeleer
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH/$omp_config.omp.json" | Invoke-Expression
# Terminal Icons
Import-Module -Name Terminal-Icons
@tomshaw
tomshaw / app.js
Created January 10, 2022 20:03
Make the mesh follow the mouse
onMouseMove(event) {
this.mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
this.mouse.y = - (event.clientY / window.innerHeight) * 2 + 1;
// Make the sphere follow the mouse
var vector = new THREE.Vector3(this.mouse.x, this.mouse.y, 0.5);
vector.unproject( this.camera );
var dir = vector.sub( this.camera.position ).normalize();
var distance = - this.camera.position.z / dir.z;
var pos = this.camera.position.clone().add( dir.multiplyScalar( distance ) );
@tomshaw
tomshaw / Container.js
Created November 7, 2021 02:31
React Bootstrap 5 Container.
import React from "react"
import PropTypes from "prop-types"
import classNames from "classnames"
import "./Container.scss"
const Container = ({ sm, md, lg, xl, xxl, fluid, ...props }) => {
let styles = {
"container-sm": sm,
"container-md": md,
"container-lg": lg,
@tomshaw
tomshaw / Form.php
Created April 7, 2021 20:33
Laravel telephone number validators.
$this->validate($request, [
'phone' => 'required|digits:10'
]);
$this->validate($request, [
'phone' => 'required|numeric|between:9,11'
]);
$this->validate($request, [
'phone' => 'required|min:10|numeric'