Skip to content

Instantly share code, notes, and snippets.

View eralston's full-sized avatar
🏠
Working from home

Erik Ralston eralston

🏠
Working from home
View GitHub Profile
@eralston
eralston / prompt.txt
Created June 22, 2023 14:05
One Prompts to Rule Them All - An AI Chat Prompt to Make AI Chat Prompts
I want you to become my Prompt Creator. Your goal is to help me craft the best possible prompt for my needs. The prompt will be used by you, ChatGPT. You will follow the following process: 1. Your first response will be to ask me what the prompt should be about. I will provide my answer, but we will need to improve it through continual iterations by going through the next steps. 2. Based on my input, you will generate 3 sections. a) Revised prompt (provide your rewritten prompt. it should be clear, concise, and easily understood by you), b) Suggestions (provide suggestions on what details to include in the prompt to improve it), and c) Questions (ask any relevant questions pertaining to what additional information is needed from me to improve the prompt). 3. We will continue this iterative process with me providing additional information to you and you updating the prompt in the Revised prompt section until it's complete.
@eralston
eralston / change-azfun-runtime-version.ps1
Last active January 21, 2023 16:41
Powershell snippets for converting an Azure Function to version 4. Very necessary given the deprecation of version 2.
# Add new settings or configuration changes to Azure Function (Can be done ahead of time):
AzureTranscriptionSettings:Key
AzureTranscriptionSettings:Region = westus
# PowerShell Setup (Can be done ahead of time)
Uninstall-AzureRm
Install-Module -Name Az.Functions -AllowClobber
Install-Module Az.Websites
# Commands to change version
using Microsoft.Extensions.Logging;
using System;
namespace Masticore
{
/// <summary>
/// Utility class for logging
/// </summary>
public static class LogUtils
{
@eralston
eralston / .bash_profile
Last active August 20, 2021 18:13
Default profile script that adds commands for easy dev workflow
[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion
alias done="git add . && git commit && git push"
alias nuke="rm -rf node_modules && npm i && npm audit fix"
alias clean="git branch --merged | grep -v \* | xargs git branch -D"
function switch() {
git fetch -pP
git checkout $1
}
@eralston
eralston / Hacks.sh
Created August 19, 2021 22:26
CLI Hacks
# Run only a single description in Jest
npm t -- -t 'can it transact?'
@eralston
eralston / git.ps1
Created July 16, 2021 13:31
PowerShell utilities for Git
# Delete all branches except trunk (and current - which will error out and not be deleted even if it's not trunk)
git branch | %{ $_.Trim() } | ?{ $_ -ne 'trunk' } | %{ git branch -D $_ }
@eralston
eralston / TypeGuards.ts
Created June 15, 2021 22:40
Useful type guards in Typescript, for validating all your inputs
function isValidNumber (it: unknown): it is number {
return it != null && typeof it === 'number' && !Number.isNaN(it)
}
@eralston
eralston / gulpfile.js
Last active November 5, 2020 21:10
Gulp + SCSS + BrowserSync Example
var gulp = require('gulp');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var sourcemaps = require('gulp-sourcemaps');
var browserSync = require('browser-sync').create();
var Paths = {
HERE: './',
DIST: 'dist/',
CSS: './assets/css/',
declare global {
namespace NodeJS {
interface ProcessEnv {
DYNAMODB_TABLE: string
SOCOTRA_INSTANCE_HOST_NAME: string
SOCOTRA_API_BASE_URI: string
SOCOTRA_AUTH_USERNAME: string
SOCOTRA_AUTH_PASSWORD: string
}
}
/**
* Utility class around window.sessionStorage that simplifies access and provides strong-typing
* */
export default class StorageValue<ValueType> {
private key: string;
private storage: Storage;
constructor(key: string, storage: Storage = sessionStorage) {
this.key = key;