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
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
version: "3.2"
services:
dev:
image: tianon/true
restart: "no"
depends_on:
- db
- redis
db:
@drnic
drnic / schema_dumper.rb
Last active May 17, 2024 20:30
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
class ApplicationReflex < StimulusReflex::Reflex
before_reflex do
jwt = ShopifyApp::JWT.new(element.data_jwt) # pass in "Bearer: blah"
if jwt
self.headers = {"jwt.shopify_domain" => jwt.shopify_domain, "jwt.shopify_user_id" => jwt.shopify_user_id}
end
end
end
web: ./bin/rackup -p "$PORT"
@drnic
drnic / Gemfile
Last active October 9, 2020 12:29
gem "google-id-token"