Skip to content

Instantly share code, notes, and snippets.

View mscoutermarsh's full-sized avatar

Mike Coutermarsh mscoutermarsh

View GitHub Profile
@mscoutermarsh
mscoutermarsh / Gemfile
Created December 8, 2023 08:06
PlanetScale API Gemfile
# frozen_string_literal: true
source "https://rubygems.org"
ruby "3.2.2"
gem "aasm"
gem "after_commit_everywhere"
gem "apipie-rails", "0.9.4"
gem "argon2", ">= 2"
def assert_equal(*args)
call_path = caller_locations(1, 1).first.path
call_line = caller_locations(1, 1).first.lineno
magic_enabled = args.length == 1
if magic_enabled
expected_value = args.first
if expected_value.is_a?(String) || expected_value.is_a?(Symbol) || expected_value.is_a?(Numeric)
formatted_value = format_value(expected_value)
@mscoutermarsh
mscoutermarsh / DR deploy example.yml
Last active July 1, 2023 19:09
GitHub Actions + PlanetScale example. Get DR number and deploy it.
steps:
- name: checkout
uses: actions/checkout@v3
- name: Setup pscale
uses: planetscale/setup-pscale-action@v1
- name: Get Deploy Requests
if: github.event.pull_request.merged == true
env:
PLANETSCALE_SERVICE_TOKEN_ID: ${{ secrets.PLANETSCALE_SERVICE_TOKEN_ID }}
PLANETSCALE_SERVICE_TOKEN: ${{ secrets.PLANETSCALE_SERVICE_TOKEN }}
@mscoutermarsh
mscoutermarsh / hcti.js
Created January 12, 2019 04:21
HTML/CSS to Image. JavaScript example (browser) https://htmlcsstoimage.com
var data = new FormData();
data.append('html', "<div class='box'>Success ✅</div>");
data.append('css', ".box { border: 4px solid #03B875; padding: 20px; font-family:'Roboto';}");
data.append('google_fonts', 'Roboto');
var xhr = new XMLHttpRequest();
xhr.open('POST', 'https://hcti.io/v1/image', true);
// Retrieve your api_id and api_key from the Dashboard. https://htmlcsstoimage.com/dashboard
xhr.setRequestHeader("Authorization", "Basic " + btoa("api_id:api_key"));
@mscoutermarsh
mscoutermarsh / main.workflow
Created October 31, 2018 17:27
GitHub Actions - install, test and deploy node.js to Zeit Now
workflow "Deploy master" {
on = "push"
resolves = [
"alias",
]
}
action "install" {
uses = "actions/npm@94e6933"
args = "install"
@mscoutermarsh
mscoutermarsh / hcti.php
Created September 3, 2018 18:40
php convert html/css to image
<?php
require 'vendor/autoload.php';
$html = "<div class='ping'>Pong ✅</div>";
$css = ".ping { padding: 20px; font-family: 'sans-serif'; }";
// Retrieve user_id/api_key from https://htmlcsstoimage.com/dashboard
$client = new GuzzleHttp\Client();
$res = $client->request('POST', 'https://hcti.io/v1/image', [
'auth' => ['user_id', 'api_key'],
@mscoutermarsh
mscoutermarsh / hcti.sh
Created September 3, 2018 01:31
curl - convert html/css to an image
# Retrieve your user id and api key from the Dashboard https://htmlcsstoimage.com/dashboard
curl -X POST https://hcti.io/v1/image -u 'UserID:APIKey'
-d "html=<div class='ping'>Pong ✅</div>"
-d "css=.ping { padding: 20px; font-family: 'sans-serif'; }"
@mscoutermarsh
mscoutermarsh / hcti.js
Last active January 10, 2021 23:49
nodejs convert html/css to image
var request = require('request');
// Retrieve your user id and api key from the Dashboard https://htmlcsstoimage.com/dashboard
var auth = { user: "user_id", pass: "api_key" };
var html = "<div class='ping'>Pong ✅</div>";
var css = ".ping { padding: 20px; font-family: 'sans-serif'; }";
var data = { html: html, css: css };
request.post({ url: 'https://hcti.io/v1/image', form: data, auth: auth }, function(err, httpResponse, body) {
console.log(body);