Skip to content

Instantly share code, notes, and snippets.

@ecwyne
ecwyne / by_office_metro.sql
Created April 3, 2024 20:27
Queries to get you started
SELECT
offices.id AS office_id,
offices.abbr AS metro_area,
substr (payments.date, 1, 7) AS mnth,
SUM(payments.amount) AS amount
FROM
payments
INNER JOIN transactions ON transactions.id = payments.transaction_id
INNER JOIN customers ON customers.id = transactions.customer_id
INNER JOIN offices ON offices.id = customers.office_id
@ecwyne
ecwyne / TypesafePusher.ts
Created July 14, 2022 15:53
Typesafe Pusher (validated with Zod)
import PusherServer from 'pusher';
import { z, ZodSchema } from 'zod';
import PusherClient from 'pusher-js';
const client = new PusherClient('...', { cluster: '...' });
const server = new PusherServer({
appId: '...',
key: '...',
secret: '...',
cluster: '...',
@ecwyne
ecwyne / rtap.ts
Created October 6, 2021 20:30
Paul Response Tap
import fetch from 'isomorphic-unfetch';
import { stringify } from 'querystring';
import pLimit from 'p-limit';
const limit = pLimit(2);
export class RTap {
private auth: string;
constructor(private accountId: number | string, secret: string) {
@ecwyne
ecwyne / extensions.conf
Created May 5, 2020 18:09
GP Phone Settings
[default]
exten => metaswitch3334,1,Goto(default,${CUT(CUT(SIP_HEADER(To),@,1),:,2)},1)
; directExtensions
exten => 1001,1,Answer()
same => n,Dial(SIP/ewyne,60)
exten => 1002,1,Answer()
same => n,Dial(SIP/dserwitz,60)
exten => 1003,1,Answer()
same => n,Dial(SIP/cmartell,60)
import { useState, useEffect, useCallback } from 'react';
type AsyncState<TData, TError = Error> = {
status: 'idle' | 'loading' | 'finished' | 'failed';
data?: TData;
error?: TError;
};
type AsyncOptions<TArgs> = {
onLoad?: boolean;
@ecwyne
ecwyne / README.md
Last active May 29, 2019 18:17
ACH.com Error Findings

Opening https://api.ach.com/webservice/V1/gateway.asmx?WSDL in chrome browser results in the following error message.

This page contains the following errors:
error on line 92 at column 1: expected '>'
Below is a rendering of the page up to the first error.

Firefox returns the following error

Consider the following example. We have a sales class that has instances with the following shape.

{
  date: '2019-04-21',
  total: 1050,
  salesperson: Ref(Class('users'), '1234')
}
@ecwyne
ecwyne / CampFireHousing.ts
Last active July 23, 2019 08:05
Serverless CampFireHousing
import fetch from 'node-fetch';
import Twitter from 'twit';
import { parse, format } from 'fecha';
import { take } from 'ramda';
const URL = 'GOOGLE_SHEETS_URL';
const T = new Twitter({
consumer_key: 'consumer_key',
consumer_secret: 'consumer_secret',
@ecwyne
ecwyne / hydra-methods.md
Last active April 20, 2017 18:24
Documentation for hydra.ready()

ready

Returns promise that resolves when initialization is complete.

/**
* @name ready
* @summary returns promise that resolves when initialization is complete
* @return {object} promise - resolving if init success or rejecting otherwise
*/
ready()
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Cellular Automata</title>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.22.1/ramda.js"></script>
<style>
.cell {
width: 5px;
height: 5px;