Skip to content

Instantly share code, notes, and snippets.

View wobsoriano's full-sized avatar
🏠
Working from home

Robert Soriano wobsoriano

🏠
Working from home
View GitHub Profile
@wobsoriano
wobsoriano / useSpeechRecognition.js
Created October 31, 2020 03:06
Speech Recognition as a Vue 3 hook
import { watch, ref } from "vue";
const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
const recognition = new SpeechRecognition();
recognition.continuous = true;
recognition.interimResults = true;
recognition.lang = "en-US";
export default function useSpeechRecognition() {
@wobsoriano
wobsoriano / useTextToSpeech.js
Created October 31, 2020 03:04
Text to Speech as a Vue hook
import { onMounted, ref } from 'vue';
export default function useTextToSpeech() {
const isLoading = ref(true);
const isSupported = ref(null);
const supportedVoices = ref([]);
const message = ref(null);
const checkIfSupported = () => {
isLoading.value = true;
@wobsoriano
wobsoriano / StackedLayout.js
Last active September 12, 2020 15:08
Dark nav with white page header (Tailwind to Chakra UI)
import {
Box,
Flex,
Image,
Link,
IconButton,
Button,
Heading,
Icon,
HStack,
@wobsoriano
wobsoriano / auth.js
Last active September 10, 2020 15:50
Firebase Auth Hook
import React, { useState, useEffect, useContext, createContext } from 'react'
import firebase from './firebase'
const AuthContext = createContext()
export const AuthProvider = ({ children }) => {
const auth = useProvideAuth()
return <AuthContext.Provider value={auth}>{children}</AuthContext.Provider>
}
@wobsoriano
wobsoriano / chatscroller.jsx
Created September 4, 2020 04:11 — forked from swyxio/chatscroller.jsx
Handy Scroll window manager component for building a Slack-like Chat experience - when you want your chat window to autoscroll down when new messages appear, BUT not while you're scrolling up. Also useful for feedlike or log display components. from ryan florence workshop chat example (course at https://courses.reacttraining.com/courses/517181/…
function ChatScroller(props) {
const ref = useRef()
const shouldScrollRef = useRef(true)
useEffect(()=> {
if (shouldScrollRef.current) {
const node = ref.current
node.scrollTop = node.scrollheight
}
})
const handleScroll = () => {
@wobsoriano
wobsoriano / index.js
Created April 6, 2020 05:17
Download external image on button click
function downloadImage(data, filename = 'untitled.jpeg') {
var a = document.createElement('a');
a.href = data;
a.download = filename;
document.body.appendChild(a);
a.click();
}
document.getElementById('btn-download').addEventListener("click", function(e) {
const canvas = document.createElement('canvas');
@wobsoriano
wobsoriano / README-Template.md
Created February 21, 2020 01:27 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@wobsoriano
wobsoriano / App.js
Created February 16, 2020 02:33
Nativebase Footer Tabs with react-navigation 5 BottomTabNavigator
import React from 'react';
import {
Container,
Header,
Content,
Footer,
FooterTab,
Button,
Icon,
Text,
@wobsoriano
wobsoriano / steps.txt
Created February 14, 2020 01:05
Eslint Prettier Create React App [2019]
Steps:
1. Install Eslint Globally
npm i -g eslint
2. Open your create-react-app react project or create one by typing
npx create-react-app name-of-project
(needs npm 5.2+)
3. Initiate Eslint in your project:
eslint --init
@wobsoriano
wobsoriano / index.jsx
Created February 13, 2020 02:59 — forked from avinmathew/index.jsx
Multiple layouts with React Router v4
import React from "react"
import { Route, Switch } from "react-router-dom"
const AppRoute = ({ component: Component, layout: Layout, ...rest }) => (
<Route {...rest} render={props => (
<Layout>
<Component {...props} />
</Layout>
)} />
)