This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'watir' | |
browser = Watir::Browser.new(:firefox) | |
browser.goto("https://www.gmail.com") | |
sleep 2 | |
browser.text_field(class: "whsOnd zHQkBf").set "YOUR EMAIL ADDRESS HERE" | |
sleep 2 | |
browser.span(index: 4).click | |
sleep 2 | |
browser.text_field(name: "password").set "YOUR EMAIL PASSWORD HERE" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts "Enter 0 for even and 1 for Odd." | |
inp = gets.to_i | |
case inp | |
when 0 | |
file = File.open("file_writer.txt",'w') | |
for i in 1..1000 do # Specify the range for EVEN loop | |
file.write(i, ' ') if i.even? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
args = ARGV | |
puts "No Arguments passed" if ARGV.empty? | |
for i in ARGV do | |
puts i | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts "Enter Credit card Number" | |
input = gets.to_s | |
if input =~ /[a-zA-Z[<>%\$~``!@#^&*()+=?;:{}\|''""'"]]/ # REGEX to validate Card Number | |
puts "Invalid Number" | |
else | |
val = input.gsub!(/[\D\s+]/, '') # val is the variable, storing the Card Number | |
if val =~ /^4/ and val.length >= 12 and val.length <= 19 | |
puts "Visa" | |
elsif val =~ /^(5|2)[1-7][0-9]/ and val.length.eql?(16) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="x-ua-compatible" content="ie=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |
<title>Landing Page</title> | |
<style> | |
#landing{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%- flash.each do |name, msg| -%> | |
<%= content_tag :div, msg, :id => "flash_#{name}" if msg.is_a?(String) %> | |
<%- end -%> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'open-uri' | |
require 'nokogiri' | |
puts 'What do you want to buy?' | |
product = gets.to_s | |
doc = Nokogiri::HTML(open("https://www.walmart.com/search/?query=#{product}")) # parsing HTML | |
file = File.new('search-results.txt', 'w+') | |
doc.xpath('//div[@class="search-result-product-title listview"]').each do |item| # Traversing through Xpath | |
file.write(item.text) | |
file.write("\n\n") | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% if flash[:notice] %> | |
<div class="success message"><span class="close">x</span><%= flash[:notice] %></div> | |
<% elsif flash[:error] %> | |
<div class="error message"><span class="close">x</span><%= flash[:error] %></div> | |
<% elsif flash[:alert] %> | |
<div class="negative message"><span class="close">x</span><%= flash[:alert] %></div> | |
<% end %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
int main(void) { | |
char str[100]; | |
int len,j,a=0,e=0,i=0,o=0,u=0; | |
printf("Enter a string : "); | |
fgets(str,100,stdin); //taking string as input | |
len = strlen(str); | |
for(int j=0;j<len;j++){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
arr = Array.new # New array Object | |
a = gets | |
a.each_char{|e| arr.push(e)} # Push each element to array | |
arr.pop | |
p arr |
OlderNewer