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 / hooks.client.js
Last active July 9, 2024 23:05
Server Side to Client Store Rehydration in SvelteKit (kinda)
import { user } from './store.js'
user.set(window__SK__USER__)
@wobsoriano
wobsoriano / page.vue
Created October 18, 2021 17:04
Nuxt 3 + socket.io
<script setup lang="ts">
import { io } from 'socket.io-client'
const connected = ref(false)
onMounted(() => {
const socket = io();
socket.on('connect', () => {
connected.value = socket.connected
@wobsoriano
wobsoriano / adonisjs_eslint_prettier_airbnb.md
Last active April 22, 2024 10:25 — forked from bradtraversy/eslint_prettier_airbnb.md
AdonisJS ESLint, Prettier & Airbnb Setup

AdonisJs VSCode - ESLint, Prettier & Airbnb Setup

1. Install ESLint & Prettier extensions for VSCode

Optional - Set format on save and any global prettier options

2. Install Packages

npm i -D eslint prettier eslint-plugin-prettier eslint-config-prettier eslint-plugin-node eslint-plugin-html eslint-config-node
@wobsoriano
wobsoriano / auth.js
Last active February 29, 2024 07:37
nuxtServerInit like implementation for Pinia
import { defineStore } from 'pinia'
export const useAuthStore = defineStore({
id: 'auth',
state: () => ({
isAuthenticated: false,
user: null
}),
actions: {
async nuxtServerInit() {
@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 / proxy.ts
Last active December 22, 2023 02:25
Nuxt 3 http-proxy-middleware
// ~/server/middleware/proxy.ts
import { defineEventHandler } from 'h3'
import { createProxyMiddleware } from 'http-proxy-middleware'; // npm install http-proxy-middleware@beta
const apiProxyMiddleware = createProxyMiddleware({
target: 'https://jsonplaceholder.typicode.com',
changeOrigin: true,
ws: true,
pathRewrite: {
'^/api/todos': '/todos',
@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 / SnackbarProvider.vue
Created July 19, 2021 07:36
Vuetify + Composition API Snackbar component that can be used globally
<template>
<div v-frag>
<slot />
<v-snackbar v-model="show" :timeout="options.timeout" bottom right>
{{ text }}
<template v-if="options.showCloseButton" #action="{ attrs }">
<v-btn
:color="options.closeButtonColor"
text
v-bind="attrs"
@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}`
}
})