Skip to content

Instantly share code, notes, and snippets.

View juliovedovatto's full-sized avatar
🤓

Julio Vedovatto juliovedovatto

🤓
View GitHub Profile
@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 / 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 / remove_duplicates_array_multi.js
Created December 3, 2016 19:42
Javascript: Remove duplicates of multidimensional array
// for browser using, this code requires javascript 1.7+
var arr = [
{ foo: 'bar', lorem: 'ipsum' },
{ foo: 'bar', lorem: 'ipsum' },
{ foo: 'bar', lorem: 'ipsum dolor sit amet' }
];
arr = arr.map(JSON.stringify).reverse() // convert to JSON string the array content, then reverse it (to check from end to begining)
.filter(function(item, index, arr){ return arr.indexOf(item, index + 1) === -1; }) // check if there is any occurence of the item in whole array
@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 / 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 / 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 / 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 <juliovedovatto@gmail.com>
* @license MIT
*/
import mitt from 'mitt'
const emitter = mitt()