Skip to content

Instantly share code, notes, and snippets.

View compwright's full-sized avatar

Jonathon Hill compwright

View GitHub Profile
@compwright
compwright / prerequest.js
Created September 30, 2016 17:08
Postman pre-request script for Joyent Signature Authentication Scheme
// Postman pre-request script for Joyent Signature Authentication
// (https://github.com/joyent/node-http-signature/blob/master/http_signing.md)
//
// Set the following vars in your Postman environment:
// apiHost
// apiKey
// apiSecret
//
// Set the following headers in Postman (copy/paste):
// Authorization: Signature keyId="{{apiKey}}",algorithm="hmac-sha256",headers="host date",signature="{{signature}}"
{
"_id" : ObjectId("58e2a3047463f61e5de6dbd6"),
"updatedAt" : ISODate("2017-04-03T19:31:16.681Z"),
"createdAt" : ISODate("2017-04-03T19:31:16.681Z"),
"name" : "Test calendar",
"active" : true,
"webhooks" : [
{
"url" : "http://localhost:8082/api/rdc/webhooks/scheduler",
"signatureAlgorithm" : "x-hub",
@compwright
compwright / javascript-disenchantment.md
Last active September 26, 2018 14:56
Javascript Disenchantment

Only in software, it’s fine if a program runs at 1% or even 0.01% of the possible performance. Everybody just seems to be ok with it....our portable computers are thousands of times more powerful than the ones that brought man to the moon. Yet every other webpage struggles to maintain a smooth 60fps scroll on the latest top-of-the-line MacBook Pro. --Nikita Prokopov, [Software disenchantment][1]

He is right!

Two questions immediately came to mind:

  1. Why do we write such bloated, inefficient software?
  2. How can we do better?
@compwright
compwright / client_automations.sql
Last active October 30, 2018 17:34
client_automations.sql
INSERT INTO `client_automations` (`client`, `source`, `status`, `credentials`, `rules`, `exclusions`, `created_timestamp`, `updated_timestamp`, `user`)
VALUES
(452,'servicetitan','active','{\"apiKey\":\"\",\"apiSecret\":\"\"}','[{\"settings\":{\"products\":[{\"code\":\"1\",\"qty\":1}],\"location\":\"7\",\"department\":null,\"cardType\":\"TY\"},\"conditions\":[{\"id\":\"0voXy6RCReZjFoa8HOQSi\",\"field\":\"invoice.total\",\"operator\":\"isMoreThan\",\"operand\":\"1.00\",\"operandType\":\"number\"}],\"isActive\":true,\"id\":\"v4sQi7iJJLl~FpKYAlaah\"}]',NULL,'2018-10-29 17:28:36','2018-10-29 17:34:14',2304),
(4799,'servicetitan','active','{\"apiKey\":\"\",\"apiSecret\":\"\"}','[{\"settings\":{\"products\":[{\"code\":\"1\",\"qty\":1}],\"location\":\"4579\",\"department\":\"4580\",\"cardType\":\"TY\"},\"conditions\":[{\"id\":\"0voXy6RCReZjFoa8HOQSi\",\"field\":\"invoice.total\",\"operator\":\"isMoreThan\",\"operand\":\"1.00\",\"operandType\":\"number\"}],\"isActive\":true,\"id\":\"v4sQi7iJJLl~FpKYAlaah\"}]',NULL,
@compwright
compwright / README.md
Last active December 12, 2019 03:13
AnomalyInnovations/serverless-bundle test case
@compwright
compwright / inject.php
Created October 22, 2019 18:35
PHP Dependency Injection in <10 lines
<?php
function inject (array $container, $class, $method) {
extract($container);
$args = array_map(
function (ReflectionParameter $arg) {
return $arg->getName();
},
(new ReflectionMethod($class, $method))->getParameters()
);
@compwright
compwright / template.html
Last active April 20, 2020 21:09
Email template with responsive text
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title></title>
<style type="text/css">
* {
-webkit-text-size-adjust:100%;
-ms-text-size-adjust:100%;
@compwright
compwright / fieldedge.json
Created May 8, 2020 18:38
FieldEdge field configuration
[
{
"name": "quoteNumber",
"label": "Quote Number",
"type": "string",
"exampleValue": ""
},
{
"name": "quotedAmountSubtotal",
"label": "Quoted Amount Subtotal",
@compwright
compwright / query.sql
Created September 18, 2020 15:39
Legacy membership migration query
SELECT
clients.id AS client_id,
clients.name AS client_name,
DATE(MAX(orders.time_stamp)) AS last_order,
clients.program AS program_id,
programs.name AS program_name,
membership_invoice.id AS last_invoice_id,
membership_invoice.total AS last_invoice_amount,
membership_invoice.payment_method AS last_invoice_payment_method,
membership_invoice.notes AS last_invoice_notes,
@compwright
compwright / run.log
Last active April 1, 2021 14:20
tys_quickbooks_replay.log
[ec2-user@ip-172-31-29-39 ~]$ php /opt/toyoursuccess/app/scripts/import/quickbooks.php --export-invoice=171102
############################
# Quickbooks export script #
############################
Exports accounting records to QuickBooks via the QuickBooks Web Connector
2021/04/01 10:01:57 [/opt/toyoursuccess/app/scripts/import/quickbooks.php] Exporting Invoice #171102
Script ran for [ec2-user@ip-172-31-29-39 ~]$ php /opt/toyoursuccess/app/scripts/import/quickbooks.php --export-invoice=171661
############################