Skip to content

Instantly share code, notes, and snippets.

View mrgenixus's full-sized avatar

Ben West mrgenixus

View GitHub Profile
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Eggnog-Style Waffles (No Eggnog Needed)</title>
</head>
<body style="margin:0; padding:0; background:#ffffff; color:#000000; font-family:Helvetica, Arial, sans-serif;">
<!-- Microdata: Recipe -->
<div itemscope itemtype="https://schema.org/Recipe" style="margin:0; padding:0;">

Postgres maintenance scripts

Note: for development use only. Please be sure not to use this with production data.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

migrate-postgresapp-to-docker.sh

Copy the contents of a db from postgres.app to a specific docker postgres instance

re-init postgres

This principally solves collations issues in template1 but can also solve any other number of problems.

#!/usr/bin/env python3
import argparse
import base64
import json
import secrets
import string
import subprocess
import sys
from typing import List
@mrgenixus
mrgenixus / loggerMiddleware.js
Created April 8, 2025 14:50
Redux Logger Middleware (simple)
export const loggerMiddleware = (logger) => (store) => (next) => async (action) => {
const response = await next(action);
logger(action.type, store.getState());
return response;
}
export default loggerMiddleware(console.log);
#consider using a 'formatter' collaborator and then using:
delegate :min_yardage, to: :formatter, prefix: formatted
# so that `formatted_min_yardage` returns the formatted value.
#A formatter might be a. PORO with a block passed to new line:
def formatter
@formatter = ModelFormatter.new(self) do
include ActionView/Helpers::NumberHelper
@mrgenixus
mrgenixus / errors_concern.rb
Created May 17, 2023 23:42
Generalized controller error handling
module ErrorHandling
def respond_with_errors(error: nil, resource: nil, status: 422, **options)
add_error(:base, error) if error.present?
self.errors = resource.errors if resource&.errors&.is_a? ActiveModel::Errors
render json {
error: errors.full_messages.to_sentence,
errors: errors,
full_errors: errors.full_messages,
success: false,
@mrgenixus
mrgenixus / Apple Signing.md
Created May 17, 2023 19:33
Apple Signing

The Apple Signing setup process (including Visual Studio Code)

For Development

Signing

App Developer Account

Your apple id must be registered as an app developer on the account. In order to give your user access to profiles and certificates, your account must have the developer-level credential, at a minimum. This will allow you to create a development certificate on your machine and upload it as well as download any relevant profiles

@mrgenixus
mrgenixus / response_json.rb
Created September 4, 2022 15:54
response_json.rb
# REF https://ruby-doc.org/stdlib-2.1.3/libdoc/json/rdoc/JSON.html#method-i-parse
module RequestJSONHelpers
def response_json
JSON.parse(response.body, object_class: HashWithIndifferentAccess)
end
end
@mrgenixus
mrgenixus / NOTES.md
Last active September 6, 2022 21:39
reducer-helpers

Expectations:

  • All Actions will use payload for values that would be in the body of a corresponding HTTP Post.
  • Actions will provide meta information as action.meta ... which a reducer can/will store as a property of an individual record
  • Values that might appear in a query string, such as id will be included in the action as top-level properties (id, post_id, comment_id, etc);
@mrgenixus
mrgenixus / plan.md
Created October 18, 2021 16:22
How to rails new

Approaches

  • Monorepo - 2 codebases: Rails (API) + Webpacker, React Runtime, no React on Rails

    • Complex deployment, Simplified test-writing, complex test-running
    • Full separation of behaviors
    • Mirrors PTE
    • Some tight-coupling allowed in deployment
    • could be easily converted to Capacitor app
    • could be built for native mobile api access
  • Multirepo (not allowed in this case) - Above +