This file contains 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 'rubygems' | |
require 'net/http' | |
require 'nokogiri' | |
require 'pry' | |
require 'open-uri' | |
module CnnScrapper | |
class CnnParser | |
URL = "http://edition.cnn.com" |
This file contains 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
Stock Options | |
79 14 3 21 104 54 12 9 94 1 96 103 | |
require 'rubygems' | |
require 'pry' | |
a =[79, 14, 3, 21, 104, 54, 12, 9, 94 , 1 , 96, 103] | |
max_profit =0 | |
max_value = a[a.size-1] |
This file contains 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 'rubygems' | |
require 'nokogiri' | |
require 'open-uri' | |
require 'pry' | |
url = "http://www.myntra.com/brands?nav_id=2" | |
doc = Nokogiri::HTML(open(url)) | |
brand_list = doc.at_css(".brands-list") | |
brand_name = [] | |
brand_list.children.css("span").find_all{|y|brand_name<< y.text} |
This file contains 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
class Contact | |
include ActiveModel::Validations | |
include ActiveModel::Serializers | |
include ActiveModel::MassAssignmentSecurity | |
include ActiveModel::Conversion | |
include ActiveModel::Naming | |
EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i |
This file contains 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 'rubygems' | |
require 'net/http' | |
require 'nokogiri' | |
require 'pry' | |
require 'open-uri' | |
module Imdb | |
class Person | |
class << self; attr_accessor :persons end | |
@persons = [] | |
attr_accessor :name,:no_of_movies |
This file contains 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 'rubygems' | |
require 'pry' | |
class ParseLog | |
attr_accessor :response | |
def initialize | |
@response= {} | |
end | |
def parse_log(file_path="/Users/amardaxini/Downloads/sample.log") |
This file contains 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
module Ups | |
class Configuration | |
attr_accessor :user_id,:password,:licence | |
def initialzie | |
user_id,password,licence=nil,nil,nil | |
end | |
end | |
class << self | |
attr_accessor :configuration | |
end |
This file contains 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
<%= form_tag('/auctions',:method=>:get) do %> | |
<%= select_tag "category_id", options_from_collection_for_select(Category.all, "id", "name") %> | |
<%= submit_tag %> | |
<% end %> | |
#In your controller | |
def index | |
if params[:category_id] | |
category= Category.find(params[:category_id]) | |
@auctions = category.auctions | |
else |
This file contains 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 you have config1 as serialize parameter it store hash than | |
# serialize :config1,Hash | |
<%= form_tag(@user_config) do |f| %> | |
<%= text_field_tag "user_config[config1][test2]" %> | |
<%= text_field_tag "user_config[config1][test1]" %> | |
<%= submit_tag %> | |
<% end %> | |
# Now you have an array |
This file contains 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
<tr> | |
<td><%[email protected](".").drop(1) %></td> | |
<td><%= @value%></td> | |
</tr> |
NewerOlder