Skip to content

Instantly share code, notes, and snippets.

View tofikhidayatxyz's full-sized avatar
🏠
Working With Cofee

Tofik Hidayat tofikhidayatxyz

🏠
Working With Cofee
View GitHub Profile
@tofikhidayatxyz
tofikhidayatxyz / svg-icon.js
Created October 26, 2020 16:03
Load svg icon using webcomponents and axios
import localforage from 'localforage'
import memoryDriver from 'localforage-memoryStorageDriver'
import {setup} from 'axios-cache-adapter'
import axios from 'axios'
class IconLoader extends HTMLElement {
constructor() {
super()
this.iconDir = '/assets/images/icons/'
this.version = document
@tofikhidayatxyz
tofikhidayatxyz / .zshrc
Created October 24, 2020 04:03
Auto switch node version using by .nvmrc file
autoload -U add-zsh-hook
load-nvmrc() {
if [[ -f .nvmrc && -r .nvmrc ]]; then
nvm use
elif [[ $(nvm version) != $(nvm version default) ]]; then
@tofikhidayatxyz
tofikhidayatxyz / README.md
Last active October 12, 2020 04:57
Vanila Reactive publish subscribe and mutate

What is this ?

This is hooks way to create reactive publish subscribe and mutator for vanila javascript, This hooks will be create new method and storing data to window object with name reactiveState.

So you can call that data with

window.reactiveState[statename].value

Or

@tofikhidayatxyz
tofikhidayatxyz / sharer.js
Last active September 26, 2020 15:56
Webcomponent for webapi sharing / navigator share
document.addEventListener('DOMContentLoaded', function() {
class SharerComponent extends HTMLElement {
constructor() {
super()
this.isCanShare = navigator.share
this.root = this.attachShadow({mode: 'open'})
this.title = this.getAttribute('title') || document.title
this.text =
this.getAttribute('text') ||
document.querySelector('meta[name=description]').getAttribute('content')
@tofikhidayatxyz
tofikhidayatxyz / app.js
Created September 5, 2020 14:39
JS countdown
const COUNTDOWN_DURATION = 20;
const ORIGIN_URL = '127.0.0.1:5500';
const showAlert = () => {
alert('JUST ALERT');
};
const mainEl = document.querySelector('#countdown-el');
const countDuration = (count = 0) => {
let currentCountdown = count;
@tofikhidayatxyz
tofikhidayatxyz / package.json
Created September 2, 2020 14:46
Simpe laravelmix config for auto prefixer
let mix = require('laravel-mix');
require('laravel-mix-purgecss');
require('laravel-mix-polyfill');
const path = require('path')
mix.options({
processCssUrls: false, // enable this if need auto process css url
postCss: [
require('autoprefixer')({
<template>
<div class="container py-5 my-5 d-flex justify-content-center flex-column">
<button class="btn btn-link mt-4" @click="$router.back()">Back</button>
<pre>
<code>{{ user }}</code>
</pre>
</div>
</template>
<script>
import axios from 'axios'
<?php
$db = mysqli_connect('localhost', 'root', '', 'ppdb');
$fetchFinal = mysqli_query($db, "
SELECT pilihan_1, pilihan_2
FROM nilaiketm
");
$jurusan = [];
$jurusanData = [];
const express = require('express')
const next = require('next')
const routes = require('./routes')
const { createProxyMiddleware } = require('http-proxy-middleware');
const port = parseInt(process.env.PORT, 10) || 3000
const dev = process.env.NODE_ENV !== "production"
const app = next({ dev })
const handle = app.getRequestHandler()
const express = require('express')
const next = require('next')
const routes = require('./routes')
const { createProxyMiddleware } = require('http-proxy-middleware');
const port = parseInt(process.env.PORT, 10) || 3000
const dev = process.env.NODE_ENV !== "production"
const app = next({ dev })
const handle = app.getRequestHandler()