Skip to content

Instantly share code, notes, and snippets.

View GabrielModog's full-sized avatar
🤠

Gabriel Tavares GabrielModog

🤠
View GitHub Profile
@GabrielModog
GabrielModog / createshape-prototype.js
Last active February 16, 2023 02:58
random prototype shape creation thing
function CreateShape(context){
this.context = context
}
CreateShape.prototype.Rect = function(width, height, x, y){
this.width = width
this.height = height
this.x = x
this.y = y
@GabrielModog
GabrielModog / vscode-extensions-ideas.md
Created September 15, 2022 06:22
VSCode extensions ideas

VSCode extensions ideas 🤔💭

  • Make available to use the webcam in the bottom of vscode
  • Import on javascript project automatically runs yarn add or another install command from a package manger
  • A tool to crop and resize images directly from the code editor

References

const content = {
title: "<h1>This is a title</h1>",
pretitle: "<h3>This is a pretitle</h3>",
description:
"<p>This is a <strong>description</strong> that's you will use</p>"
}
const tags = {
p: ["<p>", "</p>"],
h1: ["<h1>", "</h1>"],
@GabrielModog
GabrielModog / valid-sudoku.js
Last active February 17, 2023 00:11
valid a sudoku board
function validSudoku(matrix){
const rows = [], cols = [], boxes = []
matrix.forEach((_) => {
rows.push(new Set())
cols.push(new Set())
boxes.push(new Set())
})
for(let y = 0; y < matrix.length; y++){
function csvColumns(csv, indices){
const split = csv.split('\n')
const data = split.map((item) => item.split(','))
const accum = []
for(let y = 0; y < indices.length;y++){
if(data[y] === undefined) break
accum.push(data[y].filter((e, i) => indices.indexOf(i) !== -1))
}
let stack = []
let math = null
const start = (pushFn) => (pushFn => pushFn)(pushFn)
const end = (() => {
return math
})()
// const end = (function(){
@GabrielModog
GabrielModog / maze-solver-backtracking.js
Created May 28, 2022 05:23
backtracking: maze solver
const TARGET_X = 1
const TARGET_Y = 0
function isSafe(maze, x, y, MAZE_SIZE){
return (x >= 0 && x < MAZE_SIZE && y >= 0
&& y < MAZE_SIZE && maze[x][y] === 0)
}
function searchPaths(maze, x, y, solution, MAZE_SIZE){
if(x === MAZE_SIZE - 1 && y === MAZE_SIZE - 1 && maze[x][y] === 0){
@GabrielModog
GabrielModog / permute-backtracking-1.js
Last active May 28, 2022 04:42
backtracking: permute
let str = "ABC"
function swap(str, a, b){
const charArray = str.split("")
let temp = charArray[a]
charArray[a] = charArray[b]
charArray[b] = temp
return charArray.join("")
}
@GabrielModog
GabrielModog / maze-runner.js
Created May 27, 2022 02:37
6 kyu Maze Runner
function mazeRunner(maze, directions) {
let location = []
maze.forEach(function(curr, index) {
if (curr.indexOf(2) !== -1) location.push(index, curr.indexOf(2))
})
for (let step in directions) {
if (directions[step] === 'E')
location[1] += 1
@GabrielModog
GabrielModog / boxes-in-row.js
Created May 26, 2022 04:50
how much boxes has stacked in a row
// how much boxes has stacked in a row
function boxesInRow(row){
let boxes = []
for(let y in row){
let count = 0
for(let x in row){
if(row[x] !== 0){
row[x] -= 1
count++