Skip to content

Instantly share code, notes, and snippets.

View bnymn's full-sized avatar
🎯
Focusing

Bünyamin Inan bnymn

🎯
Focusing
View GitHub Profile
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
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
loop do
sleep(2)
if driver.execute_script('return document.readyState') == "complete"
break
end
end
loop do
# Wait browser to load
loop do
sleep(2)
if driver.execute_script('return document.readyState') == "complete"
break
end
end
# Load page
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
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
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;
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
module Spree
User.class_eval do
def active_for_authentication?
super && approved?
end
def inactive_message
if !approved?
:not_approved
else
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) %>