Skip to content

Instantly share code, notes, and snippets.

View yovasx2's full-sized avatar

Giovanni Alberto yovasx2

  • Vela Inc.
  • Querétaro
View GitHub Profile
// Create the iframe element
var iframe = document.createElement("iframe");
// Set the source URL for the iframe
iframe.src = "https://www.example.com";
// Set any additional attributes or styles for the iframe
iframe.setAttribute("width", "100%");
iframe.setAttribute("height", "400px");
iframe.setAttribute("frameborder", "0");
@yovasx2
yovasx2 / solution.rb
Last active February 12, 2021 18:37
screening interview: get all the combinatiosn of the menu that get the target budget
# "Fruit": 2.15,
# "Fries": 2.75,
# "Salad": 3.35,
# "Wings": 3.55,
# "Mozzarella": 4.20,
# "Plate": 5.80,
# 4.30 -> [["Fruit", "Fruit"]]
# possibleOrders(5.50) -> [["Fries", "Fries"], ["Fruit", "Salad"]]
@yovasx2
yovasx2 / solution.rb
Last active February 12, 2021 18:37
screening interview: queue using restricted size arrays
# Build a queue class with the enqueue and dequeue methods.
# The queue can store an *UNLIMITED* number of elements but you are limited to using arrays that can store up to 5 elements max
# 1# [3,4,5] 2# [6,7,8,9,10] 3# [11,12,13]
# [1#, 2#, 3#, 4#, 5#] [6#, ]
class Node
SIZE_LIMIT = 5.freeze
attr_accessor :value
attr_accessor :_next
# TODO: Define your network architecture here
import torch
from torch import nn
from torch import optim
from torchvision import datasets, transforms
import helper
# Define a transform to normalize the data
transform = transforms.Compose([transforms.ToTensor(),
transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))])
#!usr/bin/ruby
# The night sky can be modeled as an infinite 2D plane. There are N stars at distinct positions on this plane, the ith of which is at coordinates (Xi, Yi).
# A boomerang constellation is a pair of distinct equal-length line segments which share a single endpoint, such that both endpoints of each segment coincide with a star's location.
# Two boomerang constellations are distinct if they're not made up of the same unordered pair of line segments. How many distinct boomerang constellations can you spot?
# Input Format
#!usr/bin/ruby
# A string S is called a square if there is some string T such that S = T + T. For example, the strings "", aabaab" and "xxxx" are squares, but "a", "aabb" and "aabbaa" are not.
# You are given a String s. Find the longest square string that can be obtained from s by erasingsome (possibly none, possibly all) of its characters. In other words, we are looking for the longest square that occurs in s as a subsequence. Return the length of that square.
# Note that the answer is well-defined, as the square "" (the empty string) will always occur in s as a subsequence.
# Input Format
#!usr/bin/ruby
# Given a comma-separated list of equal-length strings, check if it is possible to rearrange the strings in such a way that after the rearrangement the strings at consecutive positions would differ by exactly one character.
# Example
# For input: aba,bbb,bab the output should be: false
# For input: ab,bb,aa the output should be: true
#!usr/bin/ruby
# You are given an N x M maze. The grid consists of the characters '#' and '.'
# A '#' represents a wall, and a '.' represents a walkable tile. In addition, there is a single character 'S' representing your starting position, and a single character 'T' representing the target position. You can only move upwards, downwards, leftwards and rightwards and you can only move to walkable tiles. Also, you can't move outside the grid.
# Write a program that calculates the minimum number of moves to travel from S to T. If it is impossible to reach T from S, then output DOOMED.
# Input Format
#!usr/bin/ruby
# A palindrome is a string that reads the same left-to-right and right-to-left. For example, "Madam, I'm Adam" and "Poor Dan is in a droop" are both palindromes. Note that letter case and non-alphanumeric characters should be ignored when deciding whether a string is a palindrome or not.
# А string x is an anagram of another string y if you can obtain y by rearranging the letters of x. For example, "cinema" is an anagram of "iceman", and vice versa. Note that the string and its anagram must have the same length. By definition, the string is not considered as an anagram of itself. In anagrams, non-alphanumeric characters and letter case are important. For instance, "Oo" is not the same as "oO", making "Oo" an anagram of "oO" and vice versa.
# Given a message, your task is to determine whether there is an anagram of the message that is also a palindrome.
# Example
@yovasx2
yovasx2 / capybara_custom_matcher_asset.rb
Last active May 24, 2022 08:02
Capybara custom matcher for image and favicon validation of presence and existing file
# frozen_string_literal: true
module Capybara
module CustomMatchers
include Capybara::DSL
class Asset
def asset_exists?(actual, src)
js_script = <<JSS
xhr = new XMLHttpRequest();