Skip to content

Instantly share code, notes, and snippets.

View jagoncalves14's full-sized avatar

João Gonçalves jagoncalves14

View GitHub Profile
@jagoncalves14
jagoncalves14 / use-global-properties.ts
Created October 21, 2022 10:33
[Vue] Composable for accessing Global Properties
import { getCurrentInstance } from 'vue'
export default function useGlobalProperties() {
const internalInstance = getCurrentInstance()
const globalProperties = internalInstance.appContext.config.globalProperties
return globalProperties
}
/**
@jagoncalves14
jagoncalves14 / _add-testbranch-to-zsh.md
Last active March 23, 2022 17:05
ZSH: Function to run unit tests on different files between two branches

Quickly add testbranch to your .zshrc file

Copy the script below for adding the testbranch function to your .zshrc file.

# With curl:
bash <(curl -sL https://gist.githubusercontent.com/jagoncalves14/849e38b98d8e3e80a59d43a1504da58e/raw/5c75984310095d5b8c31c883d6909dc53a17891d/add-testbranch-to-zsh.sh)

# With wget:
bash &lt;(wget -nv -O - https://gist.githubusercontent.com/jagoncalves14/849e38b98d8e3e80a59d43a1504da58e/raw/5c75984310095d5b8c31c883d6909dc53a17891d/add-testbranch-to-zsh.sh)
@jagoncalves14
jagoncalves14 / zsh-test-changes.txt
Last active March 23, 2022 12:01
ZSH: Function to run unit tests for Git's staged and unstaged files
function testchanges() {
/**
* GET THE STAGED AND UNSTAGED FILES
*/
STAGED_FILES=$(git status --porcelain | awk '{ print $2 }')
/**
* ADJUST FILES AS NEEDED
* Removing .vue or .ts extensions from each file name
@jagoncalves14
jagoncalves14 / urlMediaConverter
Created February 15, 2021 16:59
Convert URL to Embed Media URL
/**
* Converts regular YouTube and Vimeo URLs
* into valid embed media urls to be used on iframes.
* The regex's are based on these two links:
* - https://gist.github.com/harisrozak/a34fce1899ae9458d700
* - https://stackoverflow.com/a/22667308
*/
export const convertToEmbedMediaURL = (url: string): string => {
const YOUTUBE_PATTERN_REG = /^.*(?:http?s?:\/\/)?(?:www\.)?(?:youtube\.com|youtu\.be)\/(?:watch\?v=|embed\/|v\/|user\/.+\/)?([^\?&"]+).*$/
@jagoncalves14
jagoncalves14 / machine.js
Last active October 31, 2019 18:24
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions