Skip to content

Instantly share code, notes, and snippets.

View hahwul's full-sized avatar
🔥
I love coffee ☕️

HAHWUL hahwul

🔥
I love coffee ☕️
View GitHub Profile
@hahwul
hahwul / css-tooltip.css
Last active January 18, 2021 06:59
Tooltip using pure css
[data-tooltip-text]:hover {
position: relative;
}
[data-tooltip-text]:after {
-webkit-transition: bottom .3s ease-in-out, opacity .3s ease-in-out;
-moz-transition: bottom .3s ease-in-out, opacity .3s ease-in-out;
transition: bottom .3s ease-in-out, opacity .3s ease-in-out;
background-color: rgba(0, 0, 0, 0.8);
@hahwul
hahwul / darkmode.js
Created December 30, 2020 04:10
Darkmode with js
// Included this js
// <script src="https://cdn.jsdelivr.net/npm/darkmode-js@1.5.7/lib/darkmode-js.min.js"></script>
const options = {
bottom: '64px', // default: '32px'
right: 'unset', // default: '32px'
left: '32px', // default: 'unset'
time: '0.5s', // default: '0.3s'
mixColor: '#fff', // default: '#fff'
backgroundColor: '#fff', // default: '#fff'
@hahwul
hahwul / md_to_html.js
Last active December 30, 2020 04:08
Markdown to HTML
// included this js
// <script src="https://cdnjs.cloudflare.com/ajax/libs/showdown/1.9.1/showdown.min.js"></script>
function md_to_html(text) {
var converter = new showdown.Converter(),
html = converter.makeHtml(text);
return html
}
@hahwul
hahwul / parseJwt.js
Created December 30, 2020 02:34
Parsing JWT
function parseJwt (token) {
var base64Url = token.split('.')[1];
var base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
var jsonPayload = decodeURIComponent(atob(base64).split('').map(function(c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join(''));
return JSON.parse(jsonPayload);
};
@hahwul
hahwul / getParameter.js
Created December 30, 2020 02:30
Get vaule of parameter from URL
function getParameter(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}