Skip to content

Instantly share code, notes, and snippets.

Avatar
🏆
Platinum Status Level

Dr Nic Williams drnic

🏆
Platinum Status Level
  • Brisbane, Australia
  • Twitter @drnic
View GitHub Profile
@drnic
drnic / maglev.log
Last active Oct 27, 2022
If you found this because you're seeing it too - switch to Node v16
View maglev.log
$ 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
View signature_controller.js
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 Aug 15, 2022
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.
View slim-select.css
.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;
View commits-since-last-production-deploy.sh
#!/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
View docker-compose.yml
version: "3.2"
services:
dev:
image: tianon/true
restart: "no"
depends_on:
- db
- redis
db:
@drnic
drnic / schema_dumper.rb
Last active Sep 30, 2022
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.
View schema_dumper.rb
# 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
View application_reflex.rb
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
View Procfile
web: ./bin/rackup -p "$PORT"
View Gemfile
gem "google-id-token"
@drnic
drnic / AlignmentWidget.vue
Last active Jul 6, 2020
Vue component for some alignment buttons. Demo at https://share.getcloudapp.com/2Nu5bL1B
View AlignmentWidget.vue
<template>
<span class="p-1 inline-flex items-center rounded-lg bg-gray-200">
<button
@click="alignmentSelected = 'left'"
:class="alignmentSelected == 'left' ? 'bg-white shadow' : 'hover:bg-gray-400'"
class="p-1 rounded-lg"
>
<svg class="h-6 w-6 text-gray-200" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 333 333">
<path
stroke="currentColor"