Skip to content

Instantly share code, notes, and snippets.

View rodrwan's full-sized avatar
🇨🇱
cooking amazing code

Rod Fuenzalida rodrwan

🇨🇱
cooking amazing code
View GitHub Profile
// User hold user information returned by UserService
type User struct {
ID string `json:"id,omitempty" db:"id"`
Email string `json:"email,omitempty" db:"email"`
FirstName string `json:"first_name,omitempty" db:"first_name"`
LastName string `json:"last_name,omitempty" db:"last_name"`
Phone string `json:"phone,omitempty" db:"phone"`
Birthdate time.Time `json:"birthdate,omitempty" db:"birthdate"`
package queries
import (
"errors"
"github.com/rodrwan/gateway"
"github.com/rodrwan/gateway/graph"
"github.com/rodrwan/gateway/graph/types"
"github.com/graphql-go/graphql"
)
package types
import (
"github.com/rodrwan/gateway"
"github.com/graphql-go/graphql"
)
var User = graphql.NewObject(graphql.ObjectConfig{
Name: "User",
Fields: graphql.Fields{
type User struct {
ID string `json:"id" db:"id"`
FirstName string `json:"first_name" db:"first_name"`
LastName string `json:"last_name" db:"last_name"`
Email string `json:"email" db:"email"`
Birthdate time.Time `json:"birthdate" db:"birthdate"`
DNI string `json:"dni" db:"dni"`
DNIType string `json:"dni_type" db:"dni_type"`
FamilyStatus string `json:"family_status" db:"family_status"`
Gender string `json:"gender" db:"gender"`

Ejercicios programación funcional.

1.- Dado un arreglo de usuarios, determine:

  • Arreglo con emails de los usuarios que contengan la palabra “gmail”
  • Arreglo con nombres de los usuarios que hayan nacido un día impar. (Formato fecha “DD/MM/YYYY”).

2.- Dado un arreglo de alumnos, donde cada alumno tiene un nombre y un arreglo de notas, determine lo siguiente:

  • Crear un método que muestre a cada alumno con su respectivo promedio.

Ejercicios de recursividad

1.- Programar un algoritmo recursivo que calcule el factorial de un número.

2.- Programar un algoritmo recursivo que calcule un número de la serie fibonacci.

3.- Programar un algoritmo recursivo que permita hacer la división por restas sucesivas.

4.- Programar un algoritmo recursivo que permita invertir un número. Ejemplo: Entrada:123 Salida:321

const palos = ['c', 'p', 't','d']
const barajas = []
const cartas = 13
for (let i = 0; i < palos.length; i++) {
for (let j = 1; j <= cartas; j++) {
const carta = {
palo: palos[i],
valor: j,
@rodrwan
rodrwan / binary-tree.js
Last active November 6, 2024 23:28
Implementación árbol binario en JavaScript
class Node {
constructor (value) {
this.value = value
this.right = null
this.left = null
}
}
class Tree {
constructor () {
{
"data":{
"id":"d9337faf-abb2-4336-9d9c-dd78b18a291c",
"product_id":"5ad3f5f5-dd3d-4bda-aa58-ed8561ab9060",
"card_id":"611c9294-bbf7-4fd5-9606-1cc54a715e27",
"user_id":"5e8ec1ed-f2b6-4ccc-8483-bfa1c74d1861",
"payment_id":"e2l7cdbm6sxd",
"payment_url":"https://khipu.com/payment/manual/e2l7cdbm6sxd",
"current_balance":"0",
"total":345000,
const arr = [2,3,5,6,23,34,45,86];
const toFind = 23;
function indexOf (arr, num) {
let low = 0,
high = arr.length-1;
while (low <= high) {
let mid = parseInt((high + low) / 2)
let current = arr[mid]