Skip to content

Instantly share code, notes, and snippets.

View devbyray's full-sized avatar
:octocat:
Building cool things!

Dev By Ray devbyray

:octocat:
Building cool things!
View GitHub Profile
title description date categories published tags image featured
TypeScript For Beginners
In this post, I want to dive into the basics of TypeScript. We’re going to learn primitives, interfaces, enums, classes and a lot more. Sit back, grab your editor and let's get started with learning TypeScript.
2020-04-07T03:19:03.683Z
true
typescript
true
@devbyray
devbyray / is-youtube-url.ts
Created March 31, 2023 11:35
If Youtube URL JavaScript/TypeScript Regex
function isYouTubeUrl(url: string): boolean {
const regex = /^(?:(?:https?:)?\/\/)?(?:www\.)?(?:m\.)?youtu(?:\.be\/|be\.com\/watch\?v=|be\.com\/embed\/|be\.com\/v\/|be\.com\/playlist\?list=|be\.com\/.+\/.+\/.+\/.+\/.+\/.)([A-Za-z0-9_-]{11})(?:\S+)?/;
return regex.test(url);
}
node_modules/@supabase/functions-js/dist/module/types.d.ts:1:36 - error TS2304: Cannot find name 'fetch'.
1 export declare type Fetch = typeof fetch;
~~~~~
node_modules/@supabase/functions-js/dist/module/types.d.ts:38:12 - error TS2304: Cannot find name 'File'.
38 body?: File | Blob | ArrayBuffer | FormData | ReadableStream<Uint8Array> | Record<string, any> | string;
~~~~
export default {
css: [
'node_modules/lite-youtube-embed/src/lite-yt-embed.css'
]
}
import 'lite-youtube-embed'
export default {
plugins: ['@/plugins/youtube.client.js']
}
<template>
<div class="youtube">
<lite-youtube
:videoid="id"
:playlabel="label"
/>
</div>
</template>
<script>
export default {
<youtube id="5SR_NUdg7t8"></youtube>
const form = document.querySelector("#csvForm");
const csvFileInput = document.querySelector("#csvInput");
const textArea = document.querySelector("#csvResult");
form.addEventListener("submit", function (e) {
e.preventDefault();
const file = csvFileInput.files[0];
const reader = new FileReader();
reader.onload = function (e) {
const csvArray = csvToArr(e.target.result, ",");
textArea.value = JSON.stringify(csvArray, null, 4);
function csvToArr(stringValue) {
// Add logic
const [keys, ...rest] = stringVal
.trim()
.split("\n")
.map((item) => item.split(','));
const formedArr = rest.map((item) => {
const object = {};
keys.forEach((key, index) => (object[key] = item.at(index)));