Skip to content

Instantly share code, notes, and snippets.

View scarabaeus's full-sized avatar
🍹

Steve G. scarabaeus

🍹
  • San Francisco, CA
  • 18:08 (UTC -07:00)
View GitHub Profile
@scarabaeus
scarabaeus / Expression to create JSONata Expression
Last active February 23, 2023 20:19
Typed value transformation for writing UI transformation to core transformation
/* Expression to be executed on the FE to create a serialized expression to be evaluated by Core (SQL as the example) */
{
"typedValues": [
{
"value": "John",
"type": "string"
},
{
"value": "Doe",
"type": "string"
{
'grant_type': 'urn:ietf:params:oauth:grant-type:jwt-bearer',
/* Custom JSONata-registered JWT creation function ($createSignedJwt is just a pass-through wrapper on top of jsonwebtoken) */
'assertion': $createSignedJwt({
/* Service account email */
'iss': '{{client_email}}',
/* Google scoped service (url format) */
@scarabaeus
scarabaeus / Gmail to Slack JSONata
Last active February 11, 2023 03:14
Parsing multiple-part Gmail responses for Slack via JSONata
{
'channel': $.channel,
'blocks': [
{
'type': 'section',
'text': {
'type':'mrkdwn',
'text': '------------------------------\n*You have mail!*'
}
},
{
"Account": {
"Account Name": "Firefly",
"Order": [
{
"OrderID": "order103",
"Product": [
{
"Product Name": "Bowler Hat",
"ProductID": 858383,
@scarabaeus
scarabaeus / sendevent@1.0.0 Expression
Last active August 12, 2022 22:46
sendevent@1.0.0 Generic-ish transform to dump an entire context into a sendEvent call
// Merges the original context with the expected contract and then filters out the original context's properties
$ ~> | $ |
{
"instanceId": $.originatorId,
"event": "CONTINUE",
"context": $ ~> | $ | {}, ["originatorId"] |
}, [
$filter($keys($),
function($key) {
$key != "instanceId" and $key != "context" and $key != "event"
@scarabaeus
scarabaeus / Example Service Task Configuration
Last active July 21, 2022 16:32
Example Service Task Configuration
// https://try.jsonata.org/g-X7ev7nl
// Sample Input ----------------------------
{
"claim_id": 9876543212,
"policy_type": "AUTO",
"auth_token": "ABCDEF"
}
@scarabaeus
scarabaeus / gist:ec11b738a8e6e260337e1c022a5541b4
Last active June 21, 2022 05:20
XState: Guarded Transitions from `done.invoke.<service>`
...
validating: {
invoke: {
src: 'validateMobileNumber',
onDone: [
{
target: 'valid',
actions: assign({mobileNumberError: ''}),
cond: (_ctx, event) => {
const validationResponse = event.data;
@scarabaeus
scarabaeus / Demo Shopping Cart Checkout.ts
Last active March 28, 2022 17:05
Shopping Cart Checkout
// https://stately.ai/viz/7fc86d22-a6f6-4f64-a6a5-580c76cb6567
import { createMachine, assign } from "xstate";
interface Context {}
const fetchMachine = createMachine<Context>(
{
id: "Shopping Cart Checkout",
initial: "SERVICE CALL",
@scarabaeus
scarabaeus / machine.js
Created March 28, 2022 00:03
Generated by XState Viz: https://xstate.js.org/viz
const fetchMachine = Machine({
id: 'Shopping Cart Checkout',
initial: 'SERVICE_CALL',
context: {},
states: {
'SERVICE_CALL': {
invoke: {
id: 'getData',
src: 'getMockData',
onDone: {
@scarabaeus
scarabaeus / p4merge-as-git-difftool.md
Created January 16, 2022 19:46
Setting p4merge as default git difftool

Download: P4Merge https://www.perforce.com/downloads/visual-merge-tool and only copy P4Merge to /Applications from the dmg.

~ $ git config --global diff.tool p4merge
~ $ git config --global difftool.p4merge.path /Applications/p4merge.app/Contents/MacOS/p4merge
~ $ git config --global difftool.prompt false

If you receive the error message: qt.qpa.fonts: Populating font family aliases took N ms. Replace uses of missing font family "Courier" with one that exists to avoid this cost. run git difftool and in P4Merge &gt; Preferences... &gt; Text Format &gt; Font replace "Courier" with "Consolas".