Skip to content

Instantly share code, notes, and snippets.

View fathan's full-sized avatar
🎯
Focusing

Fathan Rohman fathan

🎯
Focusing
View GitHub Profile
@gquittet
gquittet / tailwind-gauge-chart.html
Last active February 23, 2025 03:22
tailwind gauge chart
<!-- percent to deg => Math.round(((value / 100) * 180 - 45) * 10) / 10 -->
<div class="relative flex aspect-[2] items-center justify-center overflow-hidden rounded-t-full bg-blue-400">
<div class="absolute top-0 aspect-square w-full rotate-[calc(72deg-45deg)] bg-gradient-to-tr from-transparent from-50% to-white to-50% transition-transform duration-500"></div>
<div class="absolute top-1/4 flex aspect-square w-3/4 justify-center rounded-full bg-blue-100"></div>
<div class="absolute bottom-0 w-full truncate text-center text-[20vmax] leading-none">40%</div>
</div>
@stevebauman
stevebauman / vue-datatables.vue
Last active March 4, 2022 00:51
Vue DataTables (Vue 3)
<template>
<div :class="classes">
<table v-once :id="tableId" ref="table" :class="className" cellpadding="0">
<thead :class="theadClassName">
<tr>
<th v-for="(field, i) in options.columns" :key="'head_' + i" :class="field.classHeaderName">
<slot :name="'HEAD_' + field.name" :field="field" :i="i">
<input
v-if="field.name === '_select_checkbox'"
type="checkbox"
@kalinchernev
kalinchernev / nest.js
Last active September 2, 2020 19:58
nest objects by 2 props: id and parent
const nest = (items, parent = 0) => {
const nested = [];
Object.values(items).forEach(item => {
// parent can be a string or a number
/* eslint-disable-next-line eqeqeq */
if (item.parent == parent) {
const children = nest(items, item.id);
if (children.length) {
@dkebler
dkebler / store-starter.js
Last active September 23, 2021 16:04
Vue dynamic/reactive nested/deep property setting and getting with vuex store
import Vue from 'vue'
import Vuex from 'vuex'
import { setProp, getProp } from 'vue-properties'
import traverse from 'traverse'
import isPlainObj from 'is-plain-object'
Vue.use(Vuex)
const store = new Vuex.Store({
state: {
//plugins/axios.js
export default function ({ $axios, app }) {
$axios.onError(error => {
const code = parseInt(error.response && error.response.status)
if ([401, 403].includes(code)) {
app.$auth.logout();
}
@JamieMason
JamieMason / group-objects-by-property.md
Created September 14, 2018 07:38
Group Array of JavaScript Objects by Key or Property Value

Group Array of JavaScript Objects by Key or Property Value

Implementation

const groupBy = key => array =>
  array.reduce((objectsByKeyValue, obj) => {
    const value = obj[key];
    objectsByKeyValue[value] = (objectsByKeyValue[value] || []).concat(obj);
    return objectsByKeyValue;
@bricksroo
bricksroo / App.vue
Last active February 7, 2024 13:03
Reveal.js in Vue
<template>
<div id="app">
<!-- <img src="./assets/logo.png">
<HelloWorld msg="Welcome to Your Vue.js App"/> -->
<div class="reveal">
<div class="slides">
<section>Single Horizontal Slide</section>
<section>
<section>Vertical Slide 1</section>
<section>Vertical Slide 2</section>
@akexorcist
akexorcist / index.js
Last active September 13, 2024 19:03
Axios post method requesting with x-www-form-urlencoded content type. See https://axios-http.com/docs/urlencoded
const axios = require('axios')
/* ... */
const params = new URLSearchParams()
params.append('name', 'Akexorcist')
params.append('age', '28')
params.append('position', 'Android Developer')
params.append('description', 'birthdate=25-12-1989&favourite=coding%20coding%20and%20coding&company=Nextzy%20Technologies&website=http://www.akexorcist.com/')
params.append('awesome', true)
@Tiriel
Tiriel / encryption.js
Last active June 21, 2024 07:53
Symetric encryption/decryption for PHP and NodeJS communication
'use strict';
const crypto = require('crypto');
const AES_METHOD = 'aes-256-cbc';
const IV_LENGTH = 16; // For AES, this is always 16, checked with php
const password = 'lbwyBzfgzUIvXZFShJuikaWvLJhIVq36'; // Must be 256 bytes (32 characters)
function encrypt(text, password) {
@zubaer-ahammed
zubaer-ahammed / Reset MySQL Root Password in Mac OS.md
Last active September 27, 2025 02:50
Reset MySQL Root Password in Mac OS

Reset mysql root password in Mac OS:

First Stop MySQL:

  1. Go to: 'System Preferences' >> 'MySQL' and stop MySQL

OR,

  1. sudo /usr/local/mysql/support-files/mysql.server start
  2. sudo /usr/local/mysql/support-files/mysql.server stop