Skip to content

Instantly share code, notes, and snippets.

View fysherman's full-sized avatar
🍒
cherry

Duy Khanh Bui fysherman

🍒
cherry
  • Viet Nam
View GitHub Profile
@-moz-document url-prefix() {
.selector {
color: lime;
}
}
@fysherman
fysherman / _responsive.scss
Created March 23, 2022 15:24
Responsive mixins scss
@mixin screen($breakpoint) {
@if $breakpoint==xs {
@media screen and (max-width: 320px) {
@content;
}
}
@if $breakpoint==sm {
@media screen and (min-width: 576px) {
@content;
}
@fysherman
fysherman / vite-scss-variable-import.js
Created March 19, 2022 09:29
Vite's global scss variable config
export default {
css: {
preprocessorOptions: {
scss: {
// example : additionalData: `@import "./src/design/styles/variables";`
// dont need include file extend .scss
additionalData: `@import "./src/path-to-scss-variables";`
},
},
},
@fysherman
fysherman / fedora_folder_lock_icon.txt
Created February 25, 2022 08:51
Linux Fedora folder lock icon
sudo chown -R $USER: $HOME
@fysherman
fysherman / set-caret-end-of-contenteditable.js
Created December 16, 2021 04:14
Set caret end of contenteditable element
function setCaretEndOfElement(element) {
if(document.createRange === undefined || window.getSelection === undefined) return;
const range = document.createRange();
const selection = window.getSelection();
range.selectNodeContents(element);
range.collapse(false);
selection!.removeAllRanges();
@fysherman
fysherman / download-file.js
Created November 15, 2021 06:54
Convert data to file and download in browser
//data: file data
// fileName: file's name to download
// typeFile: type file download. eg: text/html
function downloadFile(data, fileName, typeFile) {
const aEl = document.createElement('a')
const file = new Blob([data], { type: typeFile})
aEl.href = URL.createObjectURL(file)
aEl.download = fileName
aEl.click()
@fysherman
fysherman / index.html
Created October 31, 2021 11:14
Safe area from iphone's notch
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
@fysherman
fysherman / nuxt-scss-global-variable.js
Created October 28, 2021 04:00
Use scss global variable in Nuxt js
{
buildModules: [
'@nuxtjs/style-resources'
],
styleResources: {
scss: [
'./assets/scss/_responsive.scss', // use underscore "_" & also file extension ".scss"
'./assets/scss/_variables.scss' // use underscore "_" & also file extension ".scss"
]
}
@fysherman
fysherman / vi-to-en.js
Created October 27, 2021 02:13
Convert Vietnamese string to English
function convertViToEn(str) {
str = str.toLowerCase();
str = str.replace(/à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ/g, "a");
str = str.replace(/è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ/g, "e");
str = str.replace(/ì|í|ị|ỉ|ĩ/g, "i");
str = str.replace(/ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ/g, "o");
str = str.replace(/ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ/g, "u");
str = str.replace(/ỳ|ý|ỵ|ỷ|ỹ/g, "y");
str = str.replace(/đ/g, "d");
str = str.replace(/\u0300|\u0301|\u0303|\u0309|\u0323/g, ""); // Huyền sắc hỏi ngã nặng
let orientation = 'portrait';
if(window?.screen?.orientation?.angle && [270, 90].includes(window.screen.orientation.angle)) {
orientation = 'landscape';
} else if(window.orientation && [90, -90].includes(window.orientation)) {
orientation = 'landscape';
}