Skip to content

Instantly share code, notes, and snippets.

View danielwestendorf's full-sized avatar
🤘
rustl'n jimmies

Daniel Westendorf danielwestendorf

🤘
rustl'n jimmies
View GitHub Profile
@danielwestendorf
danielwestendorf / start.sh
Created August 9, 2023 03:34
bin slash start for a rails application which uses docker and overmind
#!/bin/bash
rm log/development.log
rm log/test.log
yarn
bundle check || bundle install
docker compose up -d
if [ -f personal.Procfile ]; then
overmind start -f personal.Procfile -t 10
class TwilioVerification
include Singleton
class << self
delegate :create, :verify, to: :instance
end
def initialize
client = Twilio::REST::Client.new(ENV["TWILIO_ACCOUNT_SID"], ENV["TWILIO_AUTH_TOKEN"])
@danielwestendorf
danielwestendorf / index.html
Created February 9, 2021 22:34
dexie-blob-error
<!doctype html>
<html>
<head>
<!-- Include Dexie -->
<script src="https://unpkg.com/dexie@latest/dist/dexie.js"></script>
<script>
//
// Define your database
//
@danielwestendorf
danielwestendorf / pre-commit
Last active May 6, 2021 15:38
Enforce codestyle automatically on git commit
#!/bin/sh
# Create this file here: ./.git/hooks/pre-commit
# chmod +x ./.git/hooks/pre-commit
.git/hooks/pre-commit-format-js
.git/hooks/pre-commit-format-ruby
curl --request POST \
--url 'https://breezypdf.com/api/pdf/html' \
--header 'Authorization: Bearer YOURKEYHERE' \
--header 'content-type: multipart/form-data' \
--form-string 'html_slug=<!DOCTYPE html><html><meta charset="UTF-8"><meta name="breezy-pdf-filename" content="myfilename.pdf"><body><h1>Hello from BreezyPDF 👍</h1><script src="https://twemoji.maxcdn.com/v/latest/twemoji.min.js" crossorigin="anonymous"></script><script type="text/javascript">twemoji.parse(document.body)</script></body></html>'
# spec/rails_helper.rb
RSpec.configure do |config|
...
config.include TurbolinkNav, type: :system
end
@danielwestendorf
danielwestendorf / JSONExtract.gs
Created June 10, 2019 22:58
A Google App Script for cell(s) which contains JSON, extracting the JSON out to columns in the sheet
/*
Export a Google Sheet cell which is JSON into columns in the sheet
Expects row 1 to define headers for the sheet
given the following table
| A | B
-------------------------------------------
1|name|data
-------------------------------------------
2|Bob|{"foo": "bar", "baz": {"eeh": "ahh"}}
<script type="text/javascript">
setTimeout(function() {
window.location = 'https://hoalife.com/traits-of-good-board-members/';
}, 1000)
</script>
# install bash-preexec
# curl https://raw.githubusercontent.com/rcaloras/bash-preexec/master/bash-preexec.sh -o ~/.bash-preexec.sh
# Add this (or source it) from your ~/.bashrc
[ -n "$PS1" ] && source ~/.bash-preexec.sh
preexec() {
if echo "$1" | grep -q -E "prod|ssh" ; then
echo -e "\033]50;SetProfile=Prod\a" # iTerm2 profile change, call AS or other here
fi
class Report
def pdf_url
Rails.cache.fetch(["v1/report-pdf-url", self]) do
asset_host = Rails.env.production? ? Rails.application.config.action_controller.asset_host : "http://localhost:3000"
metadata = { width: 8.5, width: 11 }
renderer = ReportsController.renderer.new(https: true)
html = renderer.render(template: "reports/show", assigns: { report: self })
pdf = BreezyPDF::HTML2PDF.new(asset_host, html, metadata)