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 / examples.txt
Created July 22, 2024 21:34
Tennis Score to Scorecard
Score was Bob + Charlie lost to Nic 6-3 6-7 4-6
{
"action": "scorecard",
"team_1_name": "Bob / Charlie",
"team_2_name": "Nic",
"team_1_set_1": 6,
"team_2_set_1": 3,
"team_1_set_2": 6,
"team_2_set_2": 7,
echo "When you are asked to create a list you put each item in a YAML stream document like:
---
messages:
- role: "user"
content: ITEM GOES HERE
With each one separated new line. Say nothing else except producing YAML.
" > tmp/prompt-list-20-hellos.txt
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'
@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;
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
@drnic
drnic / maglev.log
Last active October 27, 2022 23:57
If you found this because you're seeing it too - switch to Node v16
$ rails new my-awesome-site \
-m https://raw.githubusercontent.com/maglevhq/maglev-core/master/template.rb \
--database=postgresql \
--skip-action-cable
create
create README.md
create Rakefile
create .ruby-version
create config.ru
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) {