Skip to content

Instantly share code, notes, and snippets.

View mfaridzia's full-sized avatar
📒
storyteller

Muhammad Farid Zia mfaridzia

📒
storyteller
View GitHub Profile
@mfaridzia
mfaridzia / machine.js
Created November 28, 2022 09:22
Generated by XState Viz: https://xstate.js.org/viz
const trafficLightMachine = Machine({
id: "trafficLight",
initial: "green",
states: {
green: {
on: { TO_YELLOW: "yellow" }
},
yellow: {
on: { TO_RED: "red" }
},
// useCounter.js
import { ref, computed } from 'vue'
const useCounter = () => {
const count = ref(0)
const double = computed(() => count.value * 2)
const increment = () => count.value++
return {
count,
double,
@mfaridzia
mfaridzia / upload.js
Created October 7, 2021 14:04 — forked from virolea/upload.js
Tracking file upload progress using axios
upload(files) {
const config = {
onUploadProgress: function(progressEvent) {
var percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total)
console.log(percentCompleted)
}
}
let data = new FormData()
data.append('file', files[0])
@mfaridzia
mfaridzia / eslint_prettier_airbnb.md
Created March 19, 2020 09:12 — forked from bradtraversy/eslint_prettier_airbnb.md
ESLint, Prettier & Airbnb Setup

VSCode - ESLint, Prettier & Airbnb Setup

1. Install ESLint & Prettier extensions for VSCode

Optional - Set format on save and any global prettier options

2. Install Packages

npm i -D eslint prettier eslint-plugin-prettier eslint-config-prettier eslint-plugin-node eslint-config-node
@mfaridzia
mfaridzia / .gitlab-ci.yml
Created March 13, 2020 07:42 — forked from superjose/.gitlab-ci.yml
This is an example of a .gitlab-ci.yml that is required for Continuous Integration on GitLab projects.
# Reference: https://www.exclamationlabs.com/blog/continuous-deployment-to-npm-using-gitlab-ci/
# GitLab uses docker in the background, so we need to specify the
# image versions. This is useful because we're freely to use
# multiple node versions to work with it. They come from the docker
# repo.
# Uses NodeJS V 9.4.0
image: node:9.4.0
# And to cache them as well.
name: demo github actions
on: push
jobs:
build-and-publish:
name: build & publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: npm install
uses: actions/npm@master
https://www.typescriptlang.org/docs/handbook/generics.html
https://stackoverflow.com/questions/15877362/declare-and-initialize-a-dictionary-in-typescript
https://stackoverflow.com/questions/42211175/typescript-hashmap-dictionary-interface/42211573
interface IPerson<T> {
name: T;
age: T;
[Key: string]: T;
}
const Arum: IPerson<string | number> = {
name: "Arum",
age: 21,
status: "I Don't Know"
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Anime</title>
</head>
<body>
<div id="anime">
<p class="name"> dsds </p>
import { shallowMount } from '@vue/test-utils'
import TestComponent from '@/components/TestComponent.vue'
describe('TestComponent.vue', () => {
it('Merender judul text', () => {
const wrapper = shallowMount(TestComponent, {
data() {
return {
title: 'Input Data'
}