Skip to content

Instantly share code, notes, and snippets.

View hawkeye64's full-sized avatar

Jeff Galbraith hawkeye64

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'",
@hawkeye64
hawkeye64 / format.js
Created October 18, 2020 20:53
Formatted output like: print("Hello, {0}! The answer is {1}.", "World", 42);
function format(fmt, ...args) {
if (!fmt.match(/^(?:(?:(?:[^{}]|(?:\{\{)|(?:\}\}))+)|(?:\{[0-9]+\}))+$/)) {
throw new Error('invalid format string.');
}
return fmt.replace(/((?:[^{}]|(?:\{\{)|(?:\}\}))+)|(?:\{([0-9]+)\})/g, (m, str, index) => {
if (str) {
return str.replace(/(?:{{)|(?:}})/g, m => m[0]);
} else {
if (index >= args.length) {
throw new Error('argument index is out of range in format');
@hawkeye64
hawkeye64 / loadComponents.js
Created December 23, 2019 14:27
Dynamically load Vue components from a folder
export default ({ Vue }) => {
const examples = require('../assets/examples').default
for (const index in examples) {
import(
/* webpackChunkName: "examples" */
/* webpackMode: "lazy-once" */
`../examples/${examples[index].file}.vue`
).then(comp => {
Vue.component(examples[index].file, comp.default)
})
@hawkeye64
hawkeye64 / launch.json
Created August 24, 2019 23:23
launch.json for vscode
{
// Use IntelliSense to learn about possible Node.js debug attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach by Process ID",
@hawkeye64
hawkeye64 / setViewport
Created August 3, 2019 17:00
dynamically set meta based on screen width
//sweet hack to set meta viewport for desktop sites squeezing down to mobile that are big and have a fixed width
//first see if they have window.screen.width avail
(function() {
if (window.screen.width)
{
var setViewport = {
//smaller devices
phone: 'width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no',
//bigger ones, be sure to set width to the needed and likely hardcoded width of your site at large breakpoints
other: 'width=1045,user-scalable=yes',
@hawkeye64
hawkeye64 / css_colors.js
Created July 15, 2019 16:13 — forked from bobspace/css_colors.js
All of the CSS Color names as an array in javascript.
// CSS Color Names
// Compiled by @bobspace.
//
// A javascript array containing all of the color names listed in the CSS Spec.
// The full list can be found here: http://www.w3schools.com/cssref/css_colornames.asp
// Use it as you please, 'cuz you can't, like, own a color, man.
var CSS_COLOR_NAMES = ["AliceBlue","AntiqueWhite","Aqua","Aquamarine","Azure","Beige","Bisque","Black","BlanchedAlmond","Blue","BlueViolet","Brown","BurlyWood","CadetBlue","Chartreuse","Chocolate","Coral","CornflowerBlue","Cornsilk","Crimson","Cyan","DarkBlue","DarkCyan","DarkGoldenRod","DarkGray","DarkGrey","DarkGreen","DarkKhaki","DarkMagenta","DarkOliveGreen","Darkorange","DarkOrchid","DarkRed","DarkSalmon","DarkSeaGreen","DarkSlateBlue","DarkSlateGray","DarkSlateGrey","DarkTurquoise","DarkViolet","DeepPink","DeepSkyBlue","DimGray","DimGrey","DodgerBlue","FireBrick","FloralWhite","ForestGreen","Fuchsia","Gainsboro","GhostWhite","Gold","GoldenRod","Gray","Grey","Green","GreenYellow","HoneyDew","HotPink","IndianRed","Indigo","Ivory"
function getRegexForDateFromat(dateFormat) {
var dateValueRegexString =
dateFormat.replace(/MM|M|DD|D|YYYY/g, function(match, position, original) {
switch (match) {
case "M":
return "([1-9]||1[0-1])";
break;
case "MM":
return "(0[1-9]||1[0-1])";
break;
@hawkeye64
hawkeye64 / dateTimeParser.js
Created June 1, 2019 17:29
Date/Time Parser (javascript)
const parse = (input: string, format: string, key: string): string => {
const index = format.indexOf(key);
return input.slice(index, index + key.length);
};
export const dateParse = (input: string, format: string = 'YYYY-MM-DD HH.mm.ss', { epoch = 2000 } = {}): Date => {
let year = 2000;
if (format.includes('YYYY')) {
year = parseInt(parse(input, format, 'YYYY'), 10);
@hawkeye64
hawkeye64 / SVG Icon usage in Quasar
Last active March 21, 2019 12:53
SVG Icon usage in Quasar
Template Code:
<q-btn @click="home" >
<q-icon v-html="$options.filters.svg('home')" ></q-icon>
</q-btn>
Boot File:
Vue.filter("svg", function (code, options) {
options=Object.assign({
width : 20,
height : 26,
@hawkeye64
hawkeye64 / clickOutsideEvent.js
Created March 6, 2019 20:42
Vue directive (untested)
Vue.directive('click-outside', {
bind: function (el, binding, vnode) {
el.clickOutsideEvent = function (event) {
// here I check that click was outside the el and his childrens
if (!(el == event.target || el.contains(event.target))) {
// and if it did, call method provided in attribute value
vnode.context[binding.expression](event);
}
};
document.body.addEventListener('click', el.clickOutsideEvent)