Skip to content

Instantly share code, notes, and snippets.

View wobsoriano's full-sized avatar
🎯
Focusing

Robert Soriano wobsoriano

🎯
Focusing
View GitHub Profile
@wobsoriano
wobsoriano / App.vue
Last active February 26, 2024 18:20
TanStack Query + Vue Options API
<script lang="ts">
import { defineComponent, toRaw } from 'vue'
import {
QueryObserver,
type QueryKey,
type QueryObserverResult,
type QueryClient,
} from '@tanstack/query-core'
type Todo = {
userId: number
@wobsoriano
wobsoriano / extract.ts
Last active December 8, 2022 01:05
Extract Vue Component Types
import { AllowedComponentProps, Component, defineComponent, VNodeProps } from 'vue'
export type ExtractComponentProps<TComponent> =
TComponent extends new () => {
$props: infer P;
}
? Omit<P, keyof VNodeProps | keyof AllowedComponentProps>
: never;
const TestComponent = defineComponent({
@wobsoriano
wobsoriano / github-proxy-client.js
Created November 29, 2022 06:05 — forked from DavidWells/github-proxy-client.js
Full Github REST api in 34 lines of code
/* Ultra lightweight Github REST Client */
// original inspiration via https://gist.github.com/v1vendi/75d5e5dad7a2d1ef3fcb48234e4528cb
const token = 'github-token-here'
const githubClient = generateAPI('https://api.github.com', {
headers: {
'User-Agent': 'xyz',
'Authorization': `bearer ${token}`
}
})
@wobsoriano
wobsoriano / express.ts
Created November 16, 2022 17:44
Express in Nuxt
// ~/server/middleware/express.ts
import express from 'express'
import todoRoutes from '~/server/express/todo'
import userRoutes from '~/server/express/user'
const app = express()
app.use('/api/todos', todoRoutes)
app.use('/api/users', userRoutes)
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/37.0.2062.94 Chrome/37.0.2062.94 Safari/537.36
Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36
Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/600.8.9 (KHTML, like Gecko) Version/8.0.8 Safari/600.8.9
Mozilla/5.0 (iPad; CPU OS 8_4_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12H321 Safari/600.1.4
Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36
Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240
Mozilla/5.0 (Windows NT 6.3; WOW64; rv:40.0)
@wobsoriano
wobsoriano / post.js
Created November 13, 2022 09:47 — forked from pejalo/post.js
Firebase function for dynamic routing via redirect
const admin = require('firebase-admin');
function buildHtmlWithPost (post) {
const title = post.title + ' | Example Website';
var head = {
title: title,
meta: [
// This may not be a valid combination of tags for the services you need to support;
@wobsoriano
wobsoriano / deploy.js
Last active July 31, 2023 14:59
Firebase deploy only changed functions
const util = require('util');
const exec = util.promisify(require('child_process').exec);
async function deployOnlyChangedFunctions() {
const { stdout: shaOfLostCommit } = await exec('git rev-parse HEAD');
const { stdout: changedFiles } = await exec(`git log -m -1 --name-only --pretty="format:" ${shaOfLostCommit}`);
const functionsFolder = 'functions/modules/'
const filenames = changedFiles.split('\n')
.filter((line) => line.startsWith(functionsFolder))
.map((line) => line.split('/')[2])
@wobsoriano
wobsoriano / docker-help.md
Created July 20, 2022 19:10 — forked from bradtraversy/docker-help.md
Docker Commands, Help & Tips

Docker Commands, Help & Tips

Show commands & management commands

$ docker

Docker version info

@wobsoriano
wobsoriano / useAsyncData.ts
Created June 2, 2022 17:51
Nuxt 3 useAsyncData with server errors on client
import type {
AsyncData,
KeyOfRes,
PickFrom,
_Transform,
} from 'nuxt/dist/app/composables/asyncData'
import type { AsyncDataOptions, NuxtApp } from '#app'
export default async function useAsyncDataWithError<
DataT,
@wobsoriano
wobsoriano / renderComposable.ts
Created June 1, 2022 23:20
Test Vue 3 composables
import { defineComponent, h, nextTick as vueNextTick } from "vue";
import { mount } from "@vue/test-utils";
import waitFor from 'p-wait-for';
export interface RenderComposableResult<T> {
result: T;
waitFor: typeof waitFor,
nextTick: typeof vueNextTick;
}