Skip to content

Instantly share code, notes, and snippets.

View drnic's full-sized avatar
🏆
Platinum Status Level

Dr Nic Williams drnic

🏆
Platinum Status Level
View GitHub Profile
@drnic
drnic / Hello.tsx
Created June 15, 2023 23:37
In Rails apps using StimulusJS, load React components found at app/javascript/react/*/index.tsx, and make them available via Ruby helper react(name)
import React from "react";
const Hello = ({ name }: { name: string }) => <span>Hello {name}</span>;
Hello.defaultProps = { name: "World" }
export default Hello;
@drnic
drnic / ardupilot-sitl-osx-macos.md
Last active April 1, 2024 18:32
Instructions for running Ardupilot Simulation SITL within MacOS using XQuartz and Vagrant
import { Controller } from "@hotwired/stimulus"
import SignaturePad from 'signature_pad'
export default class extends Controller {
static targets = ["canvas", "input"]
connect() {
this.signaturePad = new SignaturePad(this.canvasTarget)
this.signaturePad.addEventListener("endStroke", this.endStroke)
this.resizeCanvas()
if (this.inputTarget.value) {
@drnic
drnic / schema_dumper.rb
Last active February 6, 2024 16:01
Our rails db includes our own tables/schema and the Salesforce/Heroku Connect schema (under "salesforce.*"). We place this file in config/initializers/schema_dumper.rb and now our rails db:schema:dump includes both our own tables and the salesforce. tables.
# This solution was based on https://gist.github.com/GlenCrawford/16163abab7852c1bd550547f29971c18
Rails.configuration.to_prepare do
ActiveRecord::SchemaDumper.ignore_tables = %w[
salesforce._hcmeta
salesforce._sf_event_log
salesforce._trigger_log
salesforce._trigger_log_archive
]
end
Rails Coding and Tailwind CSS specializes in providing expert guidance on Ruby on Rails, PostgreSQL, JavaScript, and now also includes expertise in Tailwind CSS for designing HTML. It assists users by solving complex coding problems, troubleshooting issues, offering best practice coding tips, aiding with database queries, and helping with responsive design using Tailwind CSS. It ensures the advice given is current with the latest versions of the technologies and includes the Tailwind CSS framework. It is equipped with a browsing tool to source up-to-date information when needed. Users can expect professional, detailed, supportive, and visually-oriented interactions. Rails Coding and Tailwind CSS avoids outdated practices and prioritizes modern, efficient, secure coding standards, and elegant design principles. If unclear on user intent, it will ask targeted questions to provide the most accurate assistance. The GPT's behavior is calibrated to engage users who are looking for technical support in a friendly, i

Example using llm to generate summary of a doc. Original https://twitter.com/simonw/status/1721644215300714973

curl -s 'https://hn.algolia.com/api/v1/items/38164046' | jq -r 'recurse(.children[]) | .author + ": " + .text' | llm -m gpt-4-turbo 'Summarise the themes of the opinions expressed here. Include direct quotes in quote markers with attribution for each theme. Fix html entities. Output markdown. Go long.'
#!/bin/bash
set -euo pipefail
# e.g. https://api.buildkite.com/v2/organizations/myorg/pipelines/mypipeline/builds/1234
build_url=${BUILD_URL}
function _curl() {
curl -sS -H "${BUILDKITE_API_AUTH?:required}" $@
}
# This is the Generic storeconnect_ci:latest build and
# can be reused to build individual app CI's.
# A Pre-built image of `storeconnect_ci:latest` is being
# store in AWS ECR at 040621143078.dkr.ecr.us-east-1.amazonaws.com/storeconnect_ci:latest
# NOTE: ARGs come from docker-compose:build/args
FROM debian:bullseye-slim
ARG PG_MAJOR='12'
ARG NODE_MAJOR='16'
#!/bin/bash
set -u
up() {
INSTANCE_TYPE=${INSTANCE_TYPE:-n1-standard-1}
(
set -x
gcloud compute instances create k3s-1 \
require "playwright"
uri = "wss://chrome.browserless.io/playwright?token=#{browserless_api_key}"
Playwright.connect_to_playwright_server(uri) do |playwright|
playwright.chromium.launch do |browser|
page = browser.new_page
page.goto("https://github.com/YusukeIwaki")
page.screenshot(path: "./YusukeIwaki.png")
end
end