Skip to content

Instantly share code, notes, and snippets.

View vacas's full-sized avatar
🌇
OOO

Miguel Vacas vacas

🌇
OOO
View GitHub Profile
@vacas
vacas / duplicate_components.sh
Created June 18, 2021 20:39
To duplicate components
# $1=<new template component name>
# $2=<new template function name>
# expected file structure
# components
# / TemplateComponent
# / index.ts
# / TemplateComponent.tsx
# / TemplateComponent.test.tsx
# / TemplateComponent.module.scss
# / templateFunction.ts
@vacas
vacas / mapbox_tiles_s3_upload.sh
Last active September 18, 2020 00:16
A simplified script to upload mapbox tiles using their API, mainly for various files - https://docs.mapbox.com/api/maps/
# update script to set variables or use parameters
username=<username here>
# remember to add token scope uploads:write
accessToken=<secret access token here>
# you can use "$1" for cli paramenter or however you please to set the path to file
pathToFile=</path/to/file here>
# to randomize id; change amount of characters after "head -c". This is mainly created for bash supported OS
export LC_CTYPE=C
randomId=$(head /dev/urandom | tr -dc a-z0-9 | head -c 6 ; echo '')
@vacas
vacas / balancedbrackets.js
Last active July 24, 2017 14:43
Learning about Data Structures (Stacks) using Hacker Rank exercise - Balanced Brackets
// Cleaner implementation without Stacks, but using its concept
function main(arr) {
var solution = [],
balanced = true;
for (var i = 0; i < arr.length; i++){
switch(arr[i]){
case '{':
case '(':
case '[':
// After reviewing the exercise again, I thought this revision is much cleaner and wanted to take out the extra function to not overcomplicate it
function flatten_array(input){
var result = [];
for (var i = 0; i < input.length; i++){
var flattened = input[i];
result = result.concat(Array.isArray(flattened) ? flatten_array(flattened) : flattened);
}
return result;
}
@vacas
vacas / soccer_api.html
Created April 4, 2017 03:12
Soccer API created for a Codetrotters student using api.football-data.org
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Soccer Test</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body>
<div class="soccerBody container">
<div class="row">
@vacas
vacas / ct_fellowship2016_2.js
Last active April 2, 2017 05:01
Codetrotters Fellowship Exercise 2 - Exercise.a: create on Math.max function from an array of numbers; Exercise.b: create a function that takes 2 array of numbers and outputs the numbers in common
// Exercise a
var arrayofnums = [1,-5,4,-3,2];
function max(array) {
var maxNumber = array[0];
for(var i = 0; i < array.length; i++){
if (array[i] > maxNumber){
maxNumber = array[i];
}
@vacas
vacas / ct_fellowship2016_1.js
Created April 2, 2017 04:32
Codetrotters Fellowsihp - Coding Challenge Interview 1. Goal: Make a function that takes 2 strings and determines if they are anagrams (made it for command line using node.js)
var prompt = require('prompt-sync')();
function checkSpell(string1, string2) {
if (string1.toUpperCase().split("").sort().join("").trim() === string2.toUpperCase().split("").sort().join("").trim()) {
return "This is an anagram";
} else {
// Just for humor's sake
return "In Trump's words: WRONG!";
}
@vacas
vacas / ct_codingchallenge2016.js
Last active April 2, 2017 04:29
Coding Challenge for Codetrotters Fellowship - Goal: Function that takes an array of whole numbers and organizes them in the largest possible number together
var arrays = [
[9, 17, 0, 50],
[ 342, 689 ],
[ 43, 5, 12, 99 ],
[ 8, 4, 100 ],
[ 0, 1, 2, 3, 4, 5, 6, 7 ]
];
function createHighestNumber(input, firstDigit, output){
while (input.length > 0) {
@vacas
vacas / ultimate-ut-cheat-sheet.md
Created December 21, 2016 21:52 — forked from yoavniran/ultimate-ut-cheat-sheet.md
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai and Sinon

The Ultimate Unit Testing Cheat-sheet

For Mocha, Chai and Sinon

using mocha/chai/sinon for node.js unit-tests? check out my utility: mocha-stirrer to easily reuse test components and mock require dependencies