Skip to content

Instantly share code, notes, and snippets.

@jgornick
jgornick / storybook-ui-wrapper.tsx
Created November 22, 2022 15:19
React Native Storybook UI Wrapper - Support Deep Linking
const { getStorybookUI } = require('@storybook/react-native')
const React = require('react')
const { useEffect, useState } = require('react')
const { Linking } = require('react-native')
const { URL } = require('react-native-url-polyfill')
export const StorybookUIWrapper = () => {
const [config, setConfig] = useState()
const [url, setUrl] = useState()
@jgornick
jgornick / jsonapi.yml
Created June 2, 2021 21:14
JSON:API - JSON Schema
$schema: http://json-schema.org/draft-06/schema#
title: JSON:API Schema
description: This is a schema for responses in the JSON:API format. For more, see
http://jsonapi.org
oneOf:
- $ref: "#/definitions/success"
- $ref: "#/definitions/failure"
- $ref: "#/definitions/info"
definitions:
success:
@jgornick
jgornick / jsonapi_oas.yml
Created June 2, 2021 20:49 — forked from naesean/jsonapi_oas.yml
OpenAPI 3.0 schemas that comply with the JSON:API 1.0 specification
JSONAPIObject:
description: Includes the current JSON:API version for this specification as well as optional meta information
type: object
required:
- version
properties:
version:
type: string
default: '1.0'
example: '1.0'
@jgornick
jgornick / jsonapi.yml
Created June 2, 2021 20:48
JSON:API - OpenAPI
openapi: 3.0.2
info:
version: 1.0.0
title: "{json:api} Specification"
description: >
An include file to define the [{json:api} 1.0 specification](http://jsonapi.org/format).
N.B. I've got some confusion going on between a validating a jsonapi schema and defining one!
This file also provides a limited demonstration of jsonapi with path items for collections, items
@jgornick
jgornick / async-storage-hook.ts
Created February 20, 2021 14:51
React Native: Async Storage Hook
/* eslint-disable no-unused-vars */
import { useEffect, useState } from 'react'
import AsyncStorage from '@react-native-community/async-storage'
import { isNil } from 'lodash';
export const useAsyncStorage =
<TValue = any>(key: string, defaultValue?: TValue):
[TValue | undefined, typeof setValue, boolean] =>
{
const [value, setLocalValue] = useState<TValue | undefined>(defaultValue);
@jgornick
jgornick / 0-readme.md
Last active May 11, 2020 18:50
HAProxy Transparent Proxy

Example

GET http://127.0.0.1:3128/todos/2 (Host: jsonplaceholder.typicode.com) <-(http)-> haproxy <-(https)-> GET https://jsonplaceholder.typicode.com/todos/2
@jgornick
jgornick / pre-push.js
Created August 17, 2018 21:07
git: Pre-push confirmation
#!/usr/bin/env node
const split = require('lodash/split');
const includes = require('lodash/includes');
const Confirm = require('prompt-confirm');
void async function() {
console.log(`HUSKY_GIT_PARAMS=${process.env.HUSKY_GIT_PARAMS}`)
console.log(`HUSKY_GIT_STDIN=${process.env.HUSKY_GIT_STDIN}`)
---
definitions:
# Link
LinkObject:
type: object
required:
- href
properties:
return Observable
.throw(new Error('This is an error message.'))
.materialize()
.delay(2000)
.dematerialize();
@jgornick
jgornick / _source
Last active December 1, 2016 19:48
SSHFS: Remote Mount
http://brettterpstra.com/2013/02/10/the-joy-of-sshfs/