Skip to content

Instantly share code, notes, and snippets.

Avatar
I love coffee!

HAHWUL hahwul

I love coffee!
View GitHub Profile
@hahwul
hahwul / css-tooltip.css
Last active Jan 18, 2021
Tooltip using pure css
View css-tooltip.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 Dec 30, 2020
Darkmode with js
View darkmode.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 Dec 30, 2020
Markdown to HTML
View md_to_html.js
// 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
}
View parseJwt.js
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 Dec 30, 2020
Get vaule of parameter from URL
View getParameter.js
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, " "));
}
You can’t perform that action at this time.