Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Building cool things!

Dev By Ray devbyray

:octocat:
Building cool things!
View GitHub Profile
View nuxt.config.js
export default {
css: [
'node_modules/lite-youtube-embed/src/lite-yt-embed.css'
]
}
View nuxt.config.js
export default {
plugins: ['@/plugins/youtube.client.js']
}
View Youtube.vue
<template>
<div class="youtube">
<lite-youtube
:videoid="id"
:playlabel="label"
/>
</div>
</template>
<script>
export default {
View youtube-embed.js
<youtube id="5SR_NUdg7t8"></youtube>
View csv-to-array-objects-form.js
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);
View csv-array-objects.js
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)));
View split-properties.js
function csvToArr(stringValue) {
// Add logic
const [keys, ...rest] = stringVal
.trim()
.split("\n")
.map((item) => item.split(','));
console.log('csv keys: ', keys);
console.log('csv values: ', rest);
}
View csv-divide-keys-rest.js
function csvToArr(stringValue) {
// Add logic
const [keys, ...rest] = stringValue.trim().split('\n');
console.log('CSV keys: ', keys);
console.log('CSV values: ', rest);
}
View csv-split-newline.js
function csvToArr(stringValue) {
// Add logic
const formattedString = stringValue.trim().split('\n');
console.log('formattedString: ', formattedString)
}
csvToArr(csvString)