Skip to content

Instantly share code, notes, and snippets.

View gogones's full-sized avatar
👋
Goo

Annas Alghoffar gogones

👋
Goo
  • Jakarta, Indonesia
View GitHub Profile
@gogones
gogones / fe_css_jds.html
Created May 13, 2019 03:39
Jawaban Tes Front-End CSS
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Modal Dialog</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
</head>
@gogones
gogones / docker_wordpress.md
Created July 28, 2020 07:47 — forked from bradtraversy/docker_wordpress.md
Docker Compose FIle For Wordpress, MySQL & phpmyadmin

Wordpress & Docker

This file will setup Wordpress, MySQL & PHPMyAdmin with a single command. Add the code below to a file called "docker-compose.yaml" and run the command

$ docker-compose up -d

# To Tear Down
$ docker-compose down --volumes
@gogones
gogones / regex-camelCase-to-dash.js
Created December 5, 2020 14:51 — forked from youssman/regex-camelCase-to-dash.js
Javascript convert camelcase to dash (hyphen)
function camelCaseToDash( myStr ) {
return myStr.replace( /([a-z])([A-Z])/g, '$1-$2' ).toLowerCase();
}
var myStr = camelCaseToDash( 'thisString' );
alert( myStr ); // => this-string
@gogones
gogones / meanMode.js
Created February 12, 2021 01:35 — forked from areagray/meanMode.js
Using the JavaScript language, have the function MeanMode(arr) take the array of numbers stored in arr and return 1 if the mode equals the mean, 0 if they don't equal each other (ie. [5, 3, 3, 3, 1] should return 1 because the mode (3) equals the mean (3)). The array will not be empty, will only contain positive integers, and will not contain m…
//Coderbyte
function MeanMode(arr) {
var sum=0,
mean, mode, midpoint, modeStr, re,
champTotal=0;
//old faithful
arr.sort(function(a, b) {
return a - b;
@gogones
gogones / axios.refresh_token.1.js
Last active October 27, 2021 03:17 — forked from Godofbrowser/axios.refresh_token.1.js
Axios interceptor for refresh token when you have multiple parallel requests. Demo implementation: https://github.com/Godofbrowser/axios-refresh-multiple-request
// for multiple requests
let isRefreshing = false;
let failedQueue = [];
const processQueue = (error, token = null) => {
failedQueue.forEach(prom => {
if (error) {
prom.reject(error);
} else {
prom.resolve(token);
@gogones
gogones / axios-interceptors-refresh-token.js
Created October 27, 2021 03:50 — forked from mkjiau/axios-interceptors-refresh-token.js
Axios interceptors for token refreshing and more than 2 async requests available
let isRefreshing = false;
let refreshSubscribers = [];
const instance = axios.create({
baseURL: Config.API_URL,
});
instance.interceptors.response.use(response => {
return response;
}, error => {
@gogones
gogones / gist:babfa2dabb7b8488f849a1f815cec946
Created November 9, 2021 09:24 — forked from whoisryosuke/gist:5b0d54926c997a6620945d780958ea74
Javascript / ES6 - Uppercase first letter of each word (2 ways) -- via: https://stackoverflow.com/a/4878800
function toTitleCase(str) {
return str.replace(/\w\S*/g, function(txt){
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
});
}
// or in ES6:
var text = "foo bar loo zoo moo";
const ucfirst = text => text.toLowerCase()
@gogones
gogones / simple-promise-retry.js
Created December 8, 2021 02:14 — forked from briancavalier/simple-promise-retry.js
A few general patterns for retries using promises
function keepTrying(otherArgs, promise) {
promise = promise||new Promise();
// try doing the important thing
if(success) {
promise.resolve(result);
} else {
setTimeout(function() {
keepTrying(otherArgs, promise);
@gogones
gogones / context-and-localstorage-using-hooks.js
Created May 18, 2022 06:10 — forked from jimode/context-and-localstorage-using-hooks.js
Providing Context and Local Storage Using Hooks
// Providing Context
// ==================
import React, {useState, useEffect} from "react"
const Context = React.createContext()
function ContextProvider({children}) {
const [allPhotos, setAllPhotos] = useState([])
const [cartItems, setCartItems] = useState([])
@gogones
gogones / README.md
Created July 6, 2022 03:49 — forked from benknight/README.md
[use-carousel] Headless UI React hook for building a scroll-based carousel

[use-carousel] Headless UI React hook for building a scroll-based carousel

BYO-UI. No CSS necessary. Inspired by react-table.

Usage:

const {
  getLeftNavProps,
 getRightNavProps,