Skip to content

Instantly share code, notes, and snippets.

View m0jimo's full-sized avatar

M0jimo m0jimo

View GitHub Profile
@hawkeye64
hawkeye64 / Quasar and Tailwind CSS
Created October 19, 2020 19:32
Quasar and Tailwind CSS
timsayshey commented on 21 Jul •
We came up with a workaround on our team to get Quasar and Tailwind to work together. Our goal was to build everything in Tailwind on Quasar but we didn't want Quasar styles loading in and taking over or conflicting with our Tailwind styles. The first thing we had to do was prevent the Quasar stylesheet from loading in however there is no option to disable it so we do a find/replace to remove it when webpack builds.
Run npm i string-replace-loader then add the following code to the extendWebpack() method in your quasar.conf.js file:
cfg.module.rules.push({
test: /client-entry\.js$/,
loader: 'string-replace-loader',
options: {
search: "import 'quasar/dist/quasar.sass'",
@jguix
jguix / recursive-promise.ts
Last active December 10, 2022 16:22
How to create a recursive promise chain. Source http://jsbin.com/qotabib/edit?js,console
// A recursive function returning Promise<number>
function recurseToZero(n) {
console.log('B. Entering recursive function for [' + n + '].');
// Once we hit zero, bail out of the recursion. The key to recursion is that
// it stops at some point, and the callstack can be "rolled" back up.
if (n === 0) {
// We could just return 0 but we do return Promise.resolve to have a consistent return type
return Promise.resolve(0);
}
// Start a NEW PROMISE CHAIN that will become the continuation of the parent
@hagemann
hagemann / slugify.js
Last active October 30, 2023 09:10
Slugify makes a string URI-friendly
function slugify(string) {
const a = 'àáâäæãåāăąçćčđďèéêëēėęěğǵḧîïíīįìıİłḿñńǹňôöòóœøōõőṕŕřßśšşșťțûüùúūǘůűųẃẍÿýžźż·/_,:;'
const b = 'aaaaaaaaaacccddeeeeeeeegghiiiiiiiilmnnnnoooooooooprrsssssttuuuuuuuuuwxyyzzz------'
const p = new RegExp(a.split('').join('|'), 'g')
return string.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(p, c => b.charAt(a.indexOf(c))) // Replace special characters
.replace(/&/g, '-and-') // Replace & with 'and'
.replace(/[^\w\-]+/g, '') // Remove all non-word characters
@javilobo8
javilobo8 / download-file.js
Last active July 27, 2024 07:41
Download files with AJAX (axios)
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
document.body.appendChild(link);
@nhagen
nhagen / PromisAllWithFails.js
Last active November 15, 2022 18:11
Wait until all promises have completed even when some reject, with Promise.all
var a = ["sdfdf", "http://oooooolol"],
handleNetErr = function(e) { return e };
Promise.all(fetch('sdfdsf').catch(handleNetErr), fetch('http://invalidurl').catch(handleNetErr))
.then(function(sdf, invalid) {
console.log(sdf, invalid) // [Response, TypeError]
})
.catch(function(err) {
console.log(err);
})
@cowboy
cowboy / ba-issemver.js
Created September 5, 2010 18:37
isSemVer - semantic version comparison for JavaScript
/*!
* isSemVer - v0.1 - 9/05/2010
* http://benalman.com/
* http://semver.org/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/