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
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) {
@drnic
drnic / slim-select.css
Last active August 15, 2022 05:13
Rewrite of https://github.com/brianvoe/slim-select stylesheet using tailwindcss. Some color/size changes for my specific project; but you can find them easily now.
.ss-main {
@apply relative inline-block select-none w-full text-slate-500;
}
.ss-main .ss-single-selected {
@apply flex cursor-pointer w-full min-h-[38px] p-[6px];
@apply bg-white border border-gray-200 shadow-sm rounded outline-0;
@apply transition-colors duration-200;
}
.ss-main .ss-single-selected.ss-disabled {
@apply bg-slate-300 cursor-not-allowed;
#!/bin/bash
help() {
echo "Usage: ./bin/commits-since-last-production-deploy [-a myapp ] [ -h ]"
exit 2
}
if ! command -v heroku &>/dev/null; then
echo "Install 'heroku' CLI"
exit 1