Skip to content

Instantly share code, notes, and snippets.

View kevinmmartins's full-sized avatar

Kevin Martins kevinmmartins

View GitHub Profile
@kevinmmartins
kevinmmartins / uber.js
Created June 13, 2022 18:47
Simple map class
// Implement a key-value store with get(key), put(key, value), delete(key) operations.
class CustomMap {
constructor() {
this._keys = [];
this._values = [];
};
put(key,value) {
this._keys.push(key)
function validatePerson(fistName, result, lastName, email) {
if (!fistName) {
result = false
}
if (!lastName) {
result = false
}
if (email.match(/^[a-zAZ.]{1,64}@[a-zA-Z.]{1,64}$/) == null) {
const MAX_VALUE = 1048575
const integerOperation = (integer) => (stack) => {
stack.push(parseInt(integer))
}
const popOperation = (stack) => {
stack.pop()
}
@kevinmmartins
kevinmmartins / getNumber.js
Created March 16, 2022 00:01
Get the average number from the middle of the list if the list is even or the middle number when the list is odd
const isEven = (num) => (num % 2 === 0)
const getNumber = (array = []) => {
const size = array.length
if(isEven(size)){
const index = size/2
return (array[index]+array[index-1])/2
}
const index = (size-1)/2
return array[index]
@kevinmmartins
kevinmmartins / palindrome.js
Created March 14, 2022 14:28
Algorithm to find the largest palindrome in a string
function SearchingChallenge(str) {
let arrayString = str.split("")
let reversedArrayString = str.split("").reverse()
let reversedString = reversedArrayString.join("")
let result = ''
let hasNext = true
let i = 0
while(hasNext){
for(let j = i + 1 ; j<= arrayString.length ; j ++){
@kevinmmartins
kevinmmartins / email-scalar-type.js
Last active March 8, 2020 12:54
Apollo GraphQL Email Scalar Type
import { gql } from 'apollo-server-express'
import { GraphQLError } from 'graphql/error'
import { Kind } from 'graphql/language'
const EMAIL_REGEX = new RegExp(
/^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/
)
const Email = gql`
"Scalar data representing email"
virtualenv -p /usr/bin/python3.6 venv ou python3 -m venv ./venv
source venv/bin/activate
@kevinmmartins
kevinmmartins / hostnameclt.sh
Created June 12, 2019 18:06
Define the real hostname
hostname -A
hostnamectl set-hostname
ping $(hostname -f)
@kevinmmartins
kevinmmartins / python_create_object_with_dict_atributes.py
Created May 6, 2019 17:51
Create a object with dict atributes
class Aggregator:
def __init__(self, *initial_data):
for dictionary in initial_data:
for key in dictionary:
setattr(self, key, dictionary[key])
@kevinmmartins
kevinmmartins / Dockerfile.imposter
Last active May 2, 2019 13:33
Docker Compose to Imposter Swagger
FROM outofcoffee/imposter-openapi