Skip to content

Instantly share code, notes, and snippets.

View blairanderson's full-sized avatar

Blair Anderson blairanderson

View GitHub Profile
@blairanderson
blairanderson / setup-script.sh
Last active October 15, 2025 02:46 — forked from theinventor/setup-script.sh
openai codex rails setup
# get your RAILS_MASTER_KEY from cat config/credentials/development.key
# get your SECRET_KEY_BASE from cat tmp/local_secret.txt
# save BOTH as env because Secrets are only available during setup
# https://developers.openai.com/codex/cloud/environments#environment-variables-and-secrets
apt-get update
apt-get install -y postgresql postgresql-contrib libpq-dev
sudo service postgresql start
sudo -u postgres createuser --superuser root
sudo -u postgres psql -c "ALTER ROLE root LOGIN;"
@blairanderson
blairanderson / command-line-rejection-list.mdc
Last active September 30, 2025 17:55
Rails 8 + Cursor Rules
---
alwaysApply: true
---
# Command Line Rejection List
## Rails command RejectList
- rails server (do not ever run rails console)
- rails console (do not ever run rails console)
#!/usr/bin/env ruby
# csv_to_schema.rb
# Usage: ruby csv_to_schema.rb path/to/file.csv table_name
# Prints a suggested Rails migration and an example seeds.rb importer (Postgres COPY).
require "csv"
require "time"
require "date"
abort("Usage: ruby #{__FILE__} path/to/file.csv table_name") unless ARGV.size == 2
@blairanderson
blairanderson / setsqsdestination.rb
Created March 22, 2023 16:08
set SQS destination. MWS is dead, but spapi likely uses a similar pattern.
business = Business.find(1)
client = business.mws
subscriptions = client.subscriptions.list_subscriptions(VDBMWS::SELLER_MARKETPLACE_US).parse.dig("SubscriptionList", "member")
subscriptions.pretty
subscriptions.each do |sub|
sqs_queue_url = sub.dig("Destination", "AttributeList", "member", "Value")
notif_type = sub.dig('NotificationType')
Rails.logger.info("client.subscriptions.delete_subscription(#{notif_type}, #{sqs_queue_url}, #{VDBMWS::SELLER_MARKETPLACE_US})")
puts client.subscriptions.delete_subscription(notif_type, sqs_queue_url, VDBMWS::SELLER_MARKETPLACE_US).parse
@blairanderson
blairanderson / jpg2png.sh
Last active March 19, 2023 18:34
jpg2png watcher script
#!/bin/bash
# Cleanup product images
# This will convert images from JPG to PNG and replace the white
# background with transparent one.
#
# SEEDED GPT4 a copy of the script from http://tech.natemurray.com/2007/12/convert-white-to-transparent.html
# Set source folder and extension
SRC_EXT=jpg
@blairanderson
blairanderson / index.mjs
Last active February 16, 2023 16:32
default / generic website scraping
import scrape from 'website-scraper'; // only as ESM, no CommonJS
const options = {
urls: ['https://www.something.com'],
recursive: true,
directory: '/public',
prettifyUrls: true,
ignoreErrors: true,
requestConcurrency: 4,
subdirectories: [
{directory: 'img', extensions: ['.jpg', '.png', '.svg']},
@blairanderson
blairanderson / rails_bootstrap.md
Last active October 17, 2025 20:53
new rails applications

create the app

rails new your_app_name --database=postgresql --skip-jbuilder --css=tailwind

cd into app

cd your_app_name
@blairanderson
blairanderson / ffmpeg-concat-mp4-videos.sh
Created November 1, 2022 14:52
ffmpeg concat mp4 videos
ffmpeg -i dockyard-diagonal.mp4 -i ship-up.mp4 -i dockyard-up.mp4 -i ship-pan.mp4 -i shipping-cranes.mp4 \
-filter_complex "[0:v] [1:v] [2:v] [3:v] [4:v]
concat=n=5:v=1:a=0 [vv] " \
-map "[vv]" mergedvideo.mp4
@blairanderson
blairanderson / netlify-cra-errors.txt
Last active August 16, 2022 16:10
Create React App netlify npm ERR! code ERESOLVE
8:33:29 AM: Build ready to start
8:33:31 AM: build-image version: d7b3dbfb0846505993c9a131894d1858074c90b4 (focal)
8:33:31 AM: build-image tag: v4.10.1
8:33:31 AM: buildbot version: aa4e1c51618610360476c8cb99b22ac3191f186e
8:33:31 AM: Fetching cached dependencies
8:33:31 AM: Failed to fetch cache, continuing with build
8:33:31 AM: Starting to prepare the repo for build
8:33:31 AM: No cached dependencies found. Cloning fresh repo
8:33:31 AM: git clone https://github.com/blairanderson/kw-perm-builder
8:33:31 AM: Preparing Git Reference refs/heads/main