Skip to content

Instantly share code, notes, and snippets.

View ryanramage's full-sized avatar

Ryan Ramage ryanramage

View GitHub Profile
import z from 'zod'
export const name = 'myFunction'
export const param = z.object({
a: z.string(),
b: z.number()
}).strict
export const returns = z.boolean()
export const MyFunctionSchema = z.function().args(param).returns(returns)
/** @typedef { z.infer<typeof MyFunctionSchema> } MyFunction */
@ryanramage
ryanramage / machine.js
Created August 10, 2020 17:36
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@ryanramage
ryanramage / niff.js
Created November 30, 2019 17:23
niff
library['_'] = function Operator_ (orca, x, y, passive) {
Operator.call(this, orca, x, y, '_', passive)
this.name = 'niff'
this.info = 'Reads offset, if equal to char'
this.ports.x = { x: -2, y: 0 }
this.ports.y = { x: -1, y: 0 }
this.ports.comparison = { x: 1, y: 0 }
this.ports.output = { x: 0, y: 1, bang: true }
@ryanramage
ryanramage / scale.js
Created September 29, 2017 14:49
Make a scaling function that maps from one range to another
const scale = (inMin, inMax, outMin, outMax) => (input) => outMin + ((outMax - outMin) * ((input - inMin) / (inMax - inMin)))
@ryanramage
ryanramage / keybase.md
Created July 12, 2017 05:27
keybase.md

Keybase proof

I hereby claim:

  • I am ryanramage on github.
  • I am ryanramage (https://keybase.io/ryanramage) on keybase.
  • I have a public key whose fingerprint is E2ED 94ED EB71 0CB3 BABE 72AD 554A 370A 6ED8 09EE

To claim this, I am signing this object:

@ryanramage
ryanramage / readme.md
Last active February 9, 2017 18:18
twilio things

Tech things

  • No insight into websocket billing (reads, writes, etc) api is not clear on this
  • Hard to do initial sync with disposable channels. new api may help but we have not upgraded
  • 2 system sync has lots of fun timing issues. All the stuff that is not in twilio pchat, we need to sync to the local machine
        channel.sendMessage(message, {
          origin: 'internal',
 sender: sender
@ryanramage
ryanramage / form.js
Created July 14, 2016 15:36
Slackbot form for multi-user
#!/usr/bin/env node
const isPhone = require('is-phone')
const RtmClient = require('@slack/client').RtmClient
const MemoryDataStore = require('@slack/client').MemoryDataStore
const RTM_EVENTS = require('@slack/client').RTM_EVENTS
const token = process.env.SLACK_TOKEN || ''
const rtm = new RtmClient(token, {
logLevel: 'error',
@ryanramage
ryanramage / response.json
Created March 1, 2016 00:22
example listings
{
"took": 9,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"hits": {
"total": 9063,
@ryanramage
ryanramage / package.json
Last active August 29, 2015 14:18
Example package.json using docker build run push
{
"name": "example",
"version": "2.1.4",
"description": "Example docker",
"scripts": {
"start": "node bin/cli",
"docker-build": "rm -rf node_modules && npm i --production && ./node_modules/docker-build-run-push/docker-build",
"docker-run": "./node_modules/docker-build-run-push/docker-run",
"docker-push": "rm -rf node_modules && npm i && make build && npm prune && ./node_modules/docker-build-run-push/docker-push"
},
@ryanramage
ryanramage / Dockerfile
Last active August 29, 2015 14:18
Example Dockerfile
FROM ryanramage/pm2-git-alpine
# Add source files & deps
ADD . /var/www/ui-widgets
WORKDIR /var/www/ui-widgets
# Define mountable directories.
VOLUME ["/var/log/ui-widgets"]