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
def fetch(file_name, url) | |
value = %x( wget --user-agent="Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36" "#{url}" -O #{file_name} ) | |
file = nil | |
if value | |
file = open(file_name) | |
end | |
file | |
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
require 'selenium-webdriver' | |
require 'nokogiri' | |
require 'capybara' | |
# Configurations | |
Capybara.register_driver :selenium do |app| | |
Capybara::Selenium::Driver.new(app, browser: :chrome) | |
end | |
Capybara.javascript_driver = :chrome | |
Capybara.configure do |config| | |
config.default_max_wait_time = 10 # seconds |
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
loop do | |
sleep(2) | |
if driver.execute_script('return document.readyState') == "complete" | |
break | |
end | |
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
loop do | |
# Wait browser to load | |
loop do | |
sleep(2) | |
if driver.execute_script('return document.readyState') == "complete" | |
break | |
end | |
end | |
# Load page |
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
def fetch(file_name, url) | |
value = %x( wget --user-agent="Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36" "#{url}" -O #{file_name} ) | |
file = nil | |
if value | |
file = open(file_name) | |
end | |
file | |
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
puts "FUNDINGS" | |
puts "=================================" | |
fundings = page.css("div.past_financing > div > div > ul.startup_rounds > li"); | |
fundings.each do |funding| | |
header = funding.css("div.details > div.header > div.type").text.gsub(/\s+/, ""); | |
date = funding.css("div.details > div.header > div.date_display").text.gsub(/\s+/, ""); | |
raised = funding.css("div.details > div.raised").text.gsub(/\s+/, ""); | |
puts "Raised: #{raised} (#{header}) (#{date})" | |
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
SET FOREIGN_KEY_CHECKS = 0; | |
SET GROUP_CONCAT_MAX_LEN=32768; | |
SET @tables = NULL; | |
SELECT GROUP_CONCAT('`', table_name, '`') INTO @tables | |
FROM information_schema.tables | |
WHERE table_schema = (SELECT DATABASE()); | |
SELECT IFNULL(@tables,'dummy') INTO @tables; | |
SET @tables = CONCAT('DROP TABLE IF EXISTS ', @tables); | |
PREPARE stmt FROM @tables; |
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 AddApprovedToUser < ActiveRecord::Migration | |
def self.up | |
add_column :spree_users, :approved, :boolean, :default => false, :null => false | |
add_index :spree_users, :approved | |
end | |
def self.down | |
remove_index :spree_users, :approved | |
remove_column :spree_users, :approved | |
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
module Spree | |
User.class_eval do | |
def active_for_authentication? | |
super && approved? | |
end | |
def inactive_message | |
if !approved? | |
:not_approved | |
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
Deface::Override.new(:virtual_path => 'spree/admin/users/_form', | |
:name => 'add_special_price_to_product_edit', | |
:insert_after => "[data-hook=admin_user_form_roles]", | |
:text => " | |
<div data-hook=\"admin_user_form_approve\" class=\"form-group\"> | |
<strong><%= Spree.t(:approve_user) %></strong> | |
<div class=\"checkbox\"> | |
<%= f.label :approved do %> | |
<%= f.check_box :approved %> | |
<%= Spree.t(:approved) %> |
OlderNewer