Skip to content

Instantly share code, notes, and snippets.

View GabrielModog's full-sized avatar
🤠

Gabriel Tavares GabrielModog

🤠
View GitHub Profile
@GabrielModog
GabrielModog / tic-tac-toe-solver.js
Created February 17, 2023 01:33
brute tic tac toe solver unfinished
function checkCol(board){
for(let y = 0; y < board.length; y++){
let countX = 0, countO = 0
for(let x = 0; x < board[y].length; x++){
const cell = board[x][y]
if(cell === 1) countX++
else if(cell === 2) countO++
}
if(countX === 3) return 1
if(countO === 3) return 2
@GabrielModog
GabrielModog / rotate-image-90-clockwise.js
Created January 31, 2023 20:57
rotate a matrix 90 degrees clockwise
const image = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
function rotateImage(img){
for(let y = 0; y < img.length; y++)
{
for(let x = y; x < img[0].length; x++)
{
[img[y][x], img[x][y]] = [img[x][y], img[y][x]]
}
@GabrielModog
GabrielModog / brute-force-typecase-name-suggestion.js
Created January 23, 2023 18:24
brute forced type case name suggestion
const str = "allowPathCascade"
const regx = /([A-Z][^A-Z]*)/g
console.log(`original string: ${str}`)
function camelCase(str) {
return str
.replace(/\s(.)/g, function($1) { return $1.toUpperCase(); })
.replace(/\s/g, '')
@GabrielModog
GabrielModog / TODO-2023.md
Last active August 14, 2024 13:47
some stuff I like to do in 2023

TODO IN 2023 🚀

  • ✅ useTimeMachine
    • undo
    • redo
    • current
    • history mode

-✅ Something with Dall-E API (OpenAi Image Gen) must be done with Nest.js and Next.js

@GabrielModog
GabrielModog / fun-string-hash-slash.js
Created January 17, 2023 22:00
fun-string-hash-slash.js
const hashBase = "da39a3ee5e6b4b0d3255bfef95601890afd80709c2"
const hashReduce = hashBase.split('').reduce((ac, cur, index, array) => {
ac.push(cur)
if(index % 6 === 5){
ac.push('-')
}
@GabrielModog
GabrielModog / calculate-leftovers-bus-seats.js
Created January 14, 2023 05:12
calculate-leftovers-bus-seats.js
function number(seats){
if(seats[0] <= 0) return 0
const calculate = seats.reduce((result, current) => {
result += current[0]
result -= current[1]
return result
@GabrielModog
GabrielModog / findDuplicateIntegers.js
Created January 10, 2023 03:23
findDuplicateIntegers
function findDuplicateIntegers(nums){
const accumulator = []
for(let i = 0; i < nums.length; i++){
if(nums[i] in accumulator){
return true
}
accumulator[nums[i]] = i
}
@GabrielModog
GabrielModog / get-step-from-python-bdd-test.js
Created November 25, 2022 05:57
get steps from python bdd test
const fs = require("fs");
const START_WORD = "@step(";
const PATH_TO_FILE = "./data/example.py";
const FILE_NAME = "./data/letters.txt";
function readFile(path) {
const data = fs.readFileSync(path, { encoding: "utf8", flag: "r" });
return data;
}
@GabrielModog
GabrielModog / extract-step-python-bdd-test.lua
Created November 24, 2022 08:35
get steps from python bdd test
local listOfSteps = {}
local newFileData = {}
local defaultMatchPattern = "('.*')"
local path = 'data/step_python_test.txt'
local target = '@step'
function file_exists(file)
local f = io.open(file, "rb")
if f then f:close() end
return f ~= nil
@GabrielModog
GabrielModog / macos-kb-shorts.md
Created October 25, 2022 20:36
macos keyboard shortcuts to help you write better code and texts

MacOs Keyboard Shortcuts ⌨️💫

Will help you out to write code more faster than before.

Shortcut What it does
Shift + Command + Up Arrow Select the text between the insertion point and the beginning of the document.
Control + E Move to the end of a line or paragraph.