Skip to content

Instantly share code, notes, and snippets.

View GabrielModog's full-sized avatar
🤠

Gabriel Tavares GabrielModog

🤠
View GitHub Profile
@GabrielModog
GabrielModog / shuffle.js
Last active February 5, 2021 03:44
clear shuffle function and/or shuffle by prototyping in Array object
const shuffle = (list) => list.sort((a, b) => Math.floor(0.5 - Math.random()))
Array.prototype.shuffle = function(){
const copy = Array.from(this);
let currentIndex = this.length;
let temporaryValue;
let randomIndex = 0;
while(0 !== currentIndex){
@GabrielModog
GabrielModog / algorithms.js
Last active February 5, 2021 03:45
some algorithms to a challenge
const isOrdinate = (integer) => {
const fixInteger = integer.toString().split('').map(Number)
const sortInteger = [...fixInteger].sort()
const compare = fixInteger.every((item, index, array) => item === sortInteger[index])
if(integer <= 0 || typeof integer === "string")
throw new Error("Isn't a positive integer!")
return compare ? "In order" : "Not in order"
};
@GabrielModog
GabrielModog / humanizeList.js
Created November 23, 2020 03:34
a function to humanize how a list will be saw
const humanizeList = (list, type) => {
const last = list.length - 2
const initial = list.slice(0, last)
const penultimate = list.slice(last, list.length)
if(type === null || type === undefined)
throw "Type is not defined or is a null value."
if(type !== "conjunction" && type !== "disjunction")
throw "The type passed is not a valid one."
@GabrielModog
GabrielModog / 21cardtricklogic.py
Created October 30, 2020 19:02
logic for 21 card trick app
# @gabrielmodog
# 07/09/2019
import random
def end(cards):
print("Your card is: ", cards[10])
def choice(count, pile_1, pile_2, pile_3):
while True:
@GabrielModog
GabrielModog / BeginnersApps.md
Last active April 25, 2021 01:40
SOME IDEAS TO BEGINNERS START TO DEVELOP THEIR APPS AND GET IDEA HOW THE THINGS WORK

SOME IDEAS TO BEGINNERS START TO DEVELOP THEIR APPS AND GET IDEA HOW THE THINGS WORK

APPS

  • counter.
  • get a porcentage based of some value.
  • todo app with the CRUD principle; only use a lib to manage states if you already finish it this project.
  • some thing using github api; the goal is list the elements consume an api.
  • food app using spooncular api; has to be able to list, search, add, edit and delete the recipe.
  • pokedex using pokemon api to consume the api, make routes and pratice the interaction with the user.
  • finance application.
@GabrielModog
GabrielModog / isObjectCopyEqual.js
Last active October 31, 2020 08:27
A function to compare two object in case the another one is a copy
const isObjectCopyEqual = (a, b) => {
const [indexedA, indexedB] = [Object.keys(a),Object.keys(b)]
if(indexedA.length !== indexedB.length)
return false
return indexedA.every(item => a[item] === b[item]);
}
@GabrielModog
GabrielModog / monthDays.js
Last active March 28, 2021 01:14
get days of the month
function monthDays(month){
const currentYear = new Date().getFullYear();
if(+month === 2){
const isFebDays = +currentYear % 400 === 0
|| (+currentYear % 4 === 0
&& +currentYear % 100 !== 0);
return isFebDays ? 29 : 28;
}
@GabrielModog
GabrielModog / factory__pattern__person.js
Last active May 6, 2020 05:03
factory pattern exercise with javascript
function Person(name, lastname, age){
const private = {};
const person = {
set: () => {
if(!name || !lastname) {
throw new Error('This element must have a name or lastname');
}
@GabrielModog
GabrielModog / recursiveBinarySearch.js
Created April 30, 2020 06:13
simple recursive binary search
const defaultCompare = (a, b) => a > b ? 1 : (a < b ? -1 : 0);
const binarySearch = (array, element, compare = defaultCompare, left = 0, right = array.length) => {
if(left > right) return -1;
const middle = Math.floor((right + left) / 2);
const comparison = compare(element, array[middle]);
return (
comparison === -1 ?
binarySearch(array, element, compare, left, middle - 1)
@GabrielModog
GabrielModog / app_ideas.md
Last active September 7, 2020 13:57
Ideias

Algumas ideias pra fazer

  • Sistema de estacionamento.
  • Lista de anotações.
  • Validação de formulários, porém criando uma própria biblioteca de validação.
  • Carrinhos de compras.
  • Visualizador de .csv
  • Chat p2p (peer-to-peer).
  • Calendario com a possilidade de fazer anatoções na data selecionada.
  • Algum app usando a API do Twitter.