Skip to content

Instantly share code, notes, and snippets.

View danvega's full-sized avatar
:octocat:
Grinding

Dan Vega danvega

:octocat:
Grinding
View GitHub Profile
@danvega
danvega / App.vue
Created December 17, 2020 16:49
SetTimeout Vue Delay
<template>
<h1>Random Dad Jokes</h1>
<p v-if="loading">Loading...</p>
<p v-else>{{ joke }}</p>
</template>
<script>
export default {
name: "App",
data() {
@danvega
danvega / App.vue
Last active March 27, 2022 22:33
Reactive Object Vue
<template>
<h1>User Details</h1>
<p><strong>ID:</strong>{{user.id}}</p>
<p><strong>Name:</strong>{{user.name}}</p>
<p><strong>Username:</strong>{{user.username}}</p>
<p><strong>Email:</strong>{{user.email}}</p>
<select v-model="selectedId">
<option v-for="n in 10" :key="n">{{n}}</option>
@danvega
danvega / settings.json
Created April 8, 2020 15:57
VS Code preferences
{
// settings
"extensions.autoCheckUpdates": true,
"workbench.settings.editor": "json",
// theme
"workbench.colorTheme": "SynthWave '84",
// editor
"editor.cursorSmoothCaretAnimation": true,
"editor.fontFamily": "Hack",
//"editor.fontFamily": "Cascadia Code",
package dev.danvega.quickstart.controller;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.RequestBuilder;
@danvega
danvega / fb-posts-delete.js
Last active December 2, 2019 15:35
Delete all facebook posts
Array.from(document.querySelectorAll('._51xa > a:nth-child(2)')).forEach(button=>button.click())
Array.from(document.querySelectorAll('.layerConfirm')).forEach(button=>button.click())
@danvega
danvega / Settings.json
Created May 13, 2019 00:56
VIsual Studio Code Settings (Home)
{
// settings
"extensions.autoCheckUpdates": true,
"workbench.settings.editor": "json",
// theme
"workbench.colorTheme": "SynthWave '84",
"workbench.iconTheme": "vscode-icons",
// editor
@danvega
danvega / TodoList.vue
Created February 7, 2019 20:43
TodoList.vue Component
<template>
<div id="app">
<h1>My Todo App</h1>
<todo-list :title="morning.title" :todos="morning.todos"></todo-list>
<todo-list :title="nightly.title" :todos="nightly.todos"></todo-list>
</div>
</template>
<script>
import TodoList from "@/components/TodoList";
@danvega
danvega / find-max-id.js
Created January 29, 2019 18:43
Find max id in array of objects: Vanilla JavaScript
const assert = require('assert');
// GIVEN AN ARRAY OF OBJECTS FIND THE LARGEST ID
const characters = [
{ id: 1, first: "Tim", last: "Draper" },
{ id: 17, first: "David", last: "Boies" },
{ id: 199, first: "Tim", last: "Kemp" },
{ id: 75, first: "Henry", last: "Mosley" },
{ id: 444, first: "Elizabeth", last: "Holmes" },
{ id: 95, first: "Donald", last: "Lucas" },
@danvega
danvega / read.js
Last active November 29, 2018 19:27
Add Article Comment
/**
* I will use our REST API to add a new comment
*/
function addComment(form){
const articleID = getId();
const author = document.getElementById("author").value;
const comment = document.getElementById("comment").value;
fetch(baseApiURL + "/articles/" + articleID + "/comments", {
method: "POST",
@danvega
danvega / teachable_course_length.js
Created November 15, 2018 17:32
Teachable Course Length
const lessons = document.querySelectorAll('.lecture-name');
let durations = [];
lessons.forEach((lesson) => {
const name = lesson.innerText;
const start = name.indexOf("(");
const end = name.indexOf(")");
const time = name.substring(start + 1,end);
if( time != '' && time != undefined && time.indexOf(":") > 0 ) {