Skip to content

Instantly share code, notes, and snippets.

View gkweb's full-sized avatar
😎

Glade gkweb

😎
View GitHub Profile
@gkweb
gkweb / copy-and-paste-netlify-config.mjs
Created June 27, 2022 03:51
Copy and paste netlify config based on ENV var
import fs from 'fs'
import path from 'path'
// Requires folder structure
// config
// -> netlify
// Run with NETLIFY_CONFIG_FILE=netlify.develop.toml node scripts/copy-netlify-config-to-root.mjs
// ^^ You get the picture
@gkweb
gkweb / generate-medicare-card-numbers.ts
Created March 16, 2022 00:51
Medicare number generator
const fs = require('fs')
// Grabbed from here: https://gist.github.com/Ugrend/09890dbc7a049651d470d1f8b6b73e1a
function randomMedicareNumber(): string {
let sum = Math.floor(Math.random() * 5) + 2
const weights = [1, 3, 7, 9, 1, 3, 7, 9]
const num = [sum]
for (let i = 0; i < 7; i++) {
const n = Math.floor(Math.random() * 10)
sum += n * weights[i + 1]
@gkweb
gkweb / Nuxt2-ts.md
Last active March 9, 2022 12:23
Nuxt 2 and Typescript in 2022

NuxtJS 2 and Vue typescript

Props:

Import PropType from @vue/runtime-core and NOT @nuxtjs/composition-api

The legacy composition-api library is outdated and no longer maintained.

import type { PropType } from '@vue/runtime-core'
@gkweb
gkweb / ph-url-validation-regex.js
Last active April 19, 2021 05:19
Pointhacks ultimate URL validation
const validateUrl = /(https?\:\/\/([\w\-]+)?.?pointhacks.com(.au)?)/gi
// In use
validateUrl.test('https://broken.com')
validateUrl.test('https://working.pointhacks.com.au')
/**
* Liteweight matchMedia
*
* @param {String} query - The media query.
* @param {Function} - onChange callback.
*/
const useMatchMedia = (query, onChange = matches => matches) => {
const mm = matchMedia(query)
// Safari still uses addListener
mm.addListener(mql => onChange(mql.matches))
@gkweb
gkweb / webvitals-easy-dimensions.css
Created April 7, 2021 23:41
Web vitals easy dimensions
/*
* author: @gkweb
* Add this as an inline style tag to the <head>
*
* Adjust for whatever media query structure you have
* Helps with CLS - The style is there immediately and this means you can set dimensions for every screensize
*/
@media screen and (min-width: 480px) {
[data-sm-width] {
@gkweb
gkweb / bulk-delete-auth0-users.js
Last active December 16, 2020 00:22
Bulk/Batch delete auth0 users
// WARNING USE WITH CAUTION! This will delete any user in the search result!!! - You have been warned!
// Quicker than setting up the Management API with all its related tooling
// Step 1 - Search for the users you want to delete in /dashboard/COUNTRYCODE/TENANT/users
// Step 2 - Open the browser console and paste the following. Be sure to read the warning at the top of the file.
Array.prototype.slice.call(document.querySelectorAll('table[data-cosmos-key=table] > tbody > tr')).forEach(e => {
setTimeout(() => {
console.log('Deleting...')
@gkweb
gkweb / vue-cheats.js
Created November 27, 2020 00:55
Vue cheats
// computed:
// Dynamic input ID - Useful for inputs / label pairs where there is no requirement to specify the ID
inputId() {
return Math.random().toString(36).substr(2, 5)
}
// Detect if slots available programmatically (no need for prop toggles!)
hasSlot() {
return this.$scopedSlots && typeof this.$scopedSlots.slotName === 'function'
}
@gkweb
gkweb / todo-placeholder.scss
Last active November 24, 2020 00:00
TODO - Placeholder
// DEMO: https://codepen.io/gkweb/pen/QWEeBeV
.todo {
opacity: 0.25;
padding: 2rem 1rem;
margin-bottom: 1rem;
background: repeating-linear-gradient(
-45deg,
transparent,
transparent 5px,

Keybase proof

I hereby claim:

  • I am gkweb on github.
  • I am gkweb (https://keybase.io/gkweb) on keybase.
  • I have a public key ASCh-WAe_b1NJ0TbbJT70d-NXeTUaigECK1QFadW_NZ6zwo

To claim this, I am signing this object: