Skip to content

Instantly share code, notes, and snippets.

View gegeke's full-sized avatar
🎯
Focusing

Gergely Muka gegeke

🎯
Focusing
  • Tricentis
  • Vienna
View GitHub Profile
@gegeke
gegeke / additionOptimizationWithForWhile2.js
Created June 7, 2019 14:48
Addition benchmarking using for while
export const addSingle = (items, noItems) => {
return new Promise((resolve) => {
let sumData = 0
let i = noItems
while(i--) {
sumData += items[i].data1
}
resolve(sumData)
})
}
@gegeke
gegeke / additionOptimizationWithJqueryEach.js
Created June 7, 2019 16:08
Addition benchmarking using $.each()
export const addSingle = (items, noItems) => {
return new Promise((resolve) => {
let sumData = 0
$.each(items, (i, el) => {
sumData += el.data1
})
resolve(sumData)
})
}
$ vue create custom-plugin
@gegeke
gegeke / apiHub_01.js
Created April 20, 2021 18:39
Creating an API HUB 01
const fetchAPI = async () => {
const response = await fetch('https://jsonplaceholder.typicode.com/todos/1')
return response
}
@gegeke
gegeke / apiHub_02.js
Created April 20, 2021 18:41
Creating an API HUB 02
// setting the params & defaulting it to null
const fetchAPI = async ({ url = null } = { url: null }) => {
if (url) {
// handling error cases with a try-catch
try {
const response = await fetch(url)
return response
} catch (err) {
console.error(err)
}
@gegeke
gegeke / apiHub_03.js
Created April 20, 2021 18:42
Creating an API HUB 03
const fetchAPI = async ({ url = null } = { url: null }) => {
if (url) {
try {
const response = await fetch(url)
// checking for errors shown in fetch
if (!response.ok) {
throw {
isError: true,
}
}
@gegeke
gegeke / apiHub_04.js
Created April 20, 2021 18:43
Creating an API HUB 04
const fetchAPI = async ({ url = null } = { url: null }) => {
if (url) {
try {
const response = await fetch(url)
if (!response.ok) {
throw {
isError: true,
}
}
// updating the return value to more sensible one
@gegeke
gegeke / apiHub_05.js
Created April 20, 2021 18:44
Creating an API HUB 05
// unification of return values - even more sensible!
const fetchAPI = async ({ url = null } = { url: null }) => {
if (url) {
try {
const response = await fetch(url)
if (!response.ok) {
throw {
isError: true,
data: [],
}
@gegeke
gegeke / apiHub_06.js
Created April 20, 2021 18:45
Creating an API HUB 06
const fetchAPI = async ({ url = null } = { url: null }) => {
if (url) {
try {
const response = await fetch(url)
if (!response.ok) {
throw {
isError: true,
data: [],
}
}
@gegeke
gegeke / VStepperStepIcon.vue
Created October 14, 2021 12:56
VStepperStepIcon
<script>
import { VStepperStep } from 'vuetify/lib/components/VStepper';
export default {
name: 'v-stepper-step-icon',
// eslint-disable-next-line
extends: VStepperStep,
methods: {
genStepContent() {
const children = [];
if (this.hasError) {