Skip to content

Instantly share code, notes, and snippets.

View juliovedovatto's full-sized avatar
🤓

Julio Vedovatto juliovedovatto

🤓
View GitHub Profile
@juliovedovatto
juliovedovatto / eventBus.js
Created November 24, 2021 14:21
Vue 2 Event Bus, using mitt library
/**
* Vue 2 Plugin to add event bus support, using mitt library
* @see https://github.com/developit/mitt
*
* @author Julio Vedovartto <[email protected]>
* @license MIT
*/
import mitt from 'mitt'
const emitter = mitt()
@juliovedovatto
juliovedovatto / nvm.bash
Created November 15, 2021 18:52
NVM shell script for node projects
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
NVM_NODE_VERSION=""
NODE_VERSION=$(node --version)
IS_WSL=0
SKIP_NVM=0
if grep -q microsoft /proc/version >/dev/null 2>&1; then
@juliovedovatto
juliovedovatto / snippet.vue
Last active November 5, 2021 22:22
VSCode Vetur Snippet for Vue 2.x components
<template>
<div class="${TM_FILENAME_BASE/(^[A-Z])|([A-Z])/${2:+-}${2:/downcase}${1:/downcase}/g}"></div>
</template>
<script>
export default {
name: '${TM_FILENAME_BASE}',
components: {},
props: {},
data() {
@juliovedovatto
juliovedovatto / git-local-ignore
Created June 3, 2021 21:07
GIT: ignoring files locally only (bash script)
#!/bin/bash
set -e
GIT_EXCLUDE_FILE="./.git/info/exclude"
[ "$#" -lt 1 ] && echo -e "Please give at least one argument" && exit 1
[ ! -d "./.git" ] && echo -e "It seems this directory is not a root dir of a git repo. Aborting." && exit 1
@juliovedovatto
juliovedovatto / uppercase-to-front.js
Last active January 21, 2021 01:41
exercise to move capital letter to the front of a string
/**
* Create a function that moves all capital letters to the front of
* a string/word. Keep the original relative
* order of all letters the same.
*
* Example:
*
* "hApPy" ➞ "APhpy"
*/
@juliovedovatto
juliovedovatto / making-change.js
Created January 21, 2021 01:03
exercise to calculate the amount of US coins, based on a given amount of money
/**
* Making Change Exercise
*
* Given an amount of money in USD, calculate the least number of
* coins needed to create the given amount of money.
*
* Example:
*
* Input: $1.67
*
@juliovedovatto
juliovedovatto / binary-tree.js
Last active January 21, 2021 00:53
JS Basic Binary Tree exercise
/**
* Binary Tree Exercise
*
* Given a binary tree, similar to shape as below, write an algorithm
* to count the number of times each `value` appears.
*
* Assumptions:
*
* 1. each node will have a `value` prop
* 2. each node may or may not have a `left` prop
import puppeteer from 'puppeteer'
const browser = await puppeteer.launch({
args: [
'--no-sandbox'
],
timeout: 10000
})
const page = await browser.newPage()
@juliovedovatto
juliovedovatto / Wordpress: Autoptimize, exclude js from combine and monification
Created December 6, 2018 18:34
Autoptimize is a exelente wordpress plugin, but it seems it ignore the blacklist from "Exclude scripts from Autoptimize" option. The plugin persists to minify and combine, instead of leaving it as it is. So I found this filter, that I can check the url and check agains the blacklist. If the js item is blacklisted, Autoptimize will skip it.
<?php
// theme functions.php
add_filter('autoptimize_filter_js_minify_excluded', function ($condition, $url) {
if (!$blacklist = get_option('autoptimize_js_exclude', false))
return true;
$blacklist = array_filter(array_map('trim', explode( ',', $blacklist)));
return count(array_filter($blacklist, function ($match) use ($url) {
@juliovedovatto
juliovedovatto / Deploybot Ignore
Last active August 16, 2018 21:01
Exclude certain paths from being uploaded
node_modules
**/node_modules
**/*.md
**/*.json
**/.gitignore
**/gulpfile.js
**/Gruntfile.js
**/package-lock.json
**/package.json