code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/destroy'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
require 'commands/about'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/dbconsole'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/runner'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/server'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/generate'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/console'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/destroy'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/generate'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/server'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
require 'commands/about'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/plugin'
| Ruby |
class CreateResults < ActiveRecord::Migration
def self.up
create_table :results do |t|
t.integer :work_id
t.integer :scan_id
t.integer :clicks
t.integer :comments
end
end
def self.down
drop_table :results
end
end
| Ruby |
class CreateSpaceTypes < ActiveRecord::Migration
def self.up
create_table :space_types do |t|
t.string :name
t.string :code
end
SpaceType.create :name => 'sina', :code => 'vid'
SpaceType.create :name => 'bilibili', :code => 'avid'
SpaceType.create :name => 'other', :code => 'id'
Sp... | Ruby |
class AddColumnPicToWork < ActiveRecord::Migration
def self.up
add_column :works, :pic_path, :string
end
def self.down
remove_column :works, :pic_path
end
end
| Ruby |
class CreateScans < ActiveRecord::Migration
def self.up
create_table :scans do |t|
t.integer :ac_type_id
t.text :description
t.timestamps
end
end
def self.down
drop_table :scans
end
end
| Ruby |
class CreateAuthor < ActiveRecord::Migration
def self.up
create_table :authors do |t|
t.string :login_name
t.string :nick_name
end
end
def self.down
drop_table :authors
end
end
| Ruby |
class CreateFlashVars < ActiveRecord::Migration
def self.up
create_table :flash_vars do |t|
t.string :vid
t.integer :work_id
end
end
def self.down
drop_table :flash_vars
end
end
| Ruby |
class AddIndexToWorks < ActiveRecord::Migration
def self.up
add_index :works, :wid, :unique => true
end
def self.down
remove_index :works, :wid
end
end
| Ruby |
class CreateWorks < ActiveRecord::Migration
def self.up
create_table :works do |t|
t.string :name
t.datetime :cdate
t.integer :wid
t.integer :ac_type_id
t.integer :author_id
t.string :author_name
t.integer :status, :default => 1 #1-正常 2-除外
t.integer :part_coun... | Ruby |
class AddColumnDanmuToResult < ActiveRecord::Migration
def self.up
add_column :results, :danmu, :integer
end
def self.down
remove_column :results, :danmu
end
end
| Ruby |
class CreateDResults < ActiveRecord::Migration
def self.up
create_table :d_results do |t|
t.integer :scan_id
t.integer :flash_var_id
t.integer :d_count
end
end
def self.down
drop_table :d_results
end
end
| Ruby |
class CreateAcTypes < ActiveRecord::Migration
def self.up
create_table :ac_types do |t|
t.string :name
t.string :page_name
t.string :page_code
end
end
def self.down
drop_table :ac_types
end
end
| Ruby |
class AddMidToAuthors < ActiveRecord::Migration
def self.up
add_column :authors, :mid, :integer
end
def self.down
remove_column :authors, :mid
end
end
| Ruby |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
# Major.create(:name... | Ruby |
#pa
#list1 => true list1_count => 30
#list2 => true list2_count => 120
namespace :bld do
desc "Export to image from database"
task :export_to_img => :environment do
require 'lib/tasks/bili_ranking_image.rb'
pa = "#{BILI_PRO_PATH}#{ENV['pa']}\\"
list1 = ENV['list1'] || true
list1 = false if list1 == ... | Ruby |
namespace :acr do
desc "Video auto copy"
task :avi_copy => :environment do
require 'csv'
pa = "#{BILI_PRO_PATH}#{ENV['pa']}\\"
csv_file = File.open "#{pa}_list.csv"
csv_data = CSV::IOReader.new(csv_file)
list_count = (ENV['list_count'] || 30).to_i
data = []
csv_data.each do |row|
d... | Ruby |
#name, wid, pa
namespace :bld do
desc "Import CSV to database"
task :save_history_data => :environment do
require 'csv'
pa = "#{BILI_PRO_PATH}#{ENV['pa']}\\"
csv_file = File.open "#{pa}_list.csv"
date_now = Time.now
puts "reading csv file..."
csv_data = CSV::IOReader.new(csv_file)
data ... | Ruby |
namespace :bilibiliranking do
desc "bilibili ranking #7"
task :r7 => :environment do
require 'lib/tasks/vegas_video_maker.rb'
require 'lib/tasks/bili_ranking_maker.rb'
include VegasVideoMaker
date_now = Time.now
puts "Task start~"
#======================================
pa = "#{BILI_PRO_... | Ruby |
#id1 前,default=0; id2 后,default=last.id; pa, 必须有except.yml
namespace :bld do
desc "Export to CSV"
task :export_to_csv => :environment do
puts time = Time.now
pa = ENV['pa'] ? "#{BILI_PRO_PATH}#{ENV['pa']}\\" : nil
step_index = 0
id1 = ENV['id1'].to_i
id2 = ENV['id2'] || Scan.last.id
except_i... | Ruby |
namespace :bld do
desc "Get data"
task :get_acr_data => :environment do
date_now = Time.now
ac_types = ENV['codes'] ? AcType.find_all_by_page_code(ENV['codes'].split(',')) : AcType.all
pages = Scan.search ac_types
puts "#{Time.now - date_now} second complete"
date_now = Time.now
puts "proc... | Ruby |
module VegasVideoMaker
class VVM
require 'rexml/document'
@project = nil
@medias = []
@video_event_count = 0
@audio_event_count = 0
def self.create
vvm = self.new()
doc = REXML::Document.new("<?xml version=\"1.0\"?><Vegas/>")
vegas = doc.root
project = vegas.add_element "Project"
p... | Ruby |
class BiliRankingImage
require 'RMagick'
include Magick
attr_accessor :path
alias :pa :path
alias :pa= :path=
FONT_EXE = "#{RAILS_ROOT}/public/acfun_list_font_pic.exe"
TMP_FILE = 'tmp.png'
@@iconv ||= Iconv.new 'GB18030', 'UTF-8//IGNORE'
FONT_FZZHY_GBK = @@iconv.iconv "方正准圆_GBK"
FONT_FZKTJ = @@icon... | Ruby |
module VegasVideoMaker
class BRM < VVM
attr_accessor :vt, :pa, :ut #:ut => usual_time
alias :vvmtime :vt
alias :vvmtime= :vt=
TIME_30 = VVMTime.ns(1)
TIME_25 = VVMTime.nl(25)
TIME_20 = VVMTime.nl(20)
TIME_15 = VVMTime.nl(15)
TIME_10 = VVMTime.nl(10)
TIME_5 = VVMTime.nl(5)
VI... | Ruby |
namespace :bld do
desc "get data and export"
task :bat => :environment do
Rake::Task['bld:get_acr_data'].invoke
Rake::Task['bld:get_work_info'].invoke
Rake::Task['bld:fix_d_data_from_search'].invoke
Rake::Task['bld:export_to_csv'].invoke
end
end
| Ruby |
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format
# (all these examples are active by default):
# ActiveSupport::Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person',... | Ruby |
# Be sure to restart your server when you modify this file.
# These settings change the behavior of Rails 2 apps and will be defaults
# for Rails 3. You can remove this initializer when Rails 3 is released.
if defined?(ActiveRecord)
# Include Active Record class name as root for JSON serialized output.
ActiveReco... | Ruby |
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
# Mime::Type.register_alias "text/html", :iphone
| Ruby |
# Be sure to restart your server when you modify this file.
# Your secret key for verifying cookie session data integrity.
# If you change this key, all old sessions will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
Act... | Ruby |
# Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
# You can also remove all the silencers if you're trying do debug a probl... | Ruby |
# Settings specified here will take precedence over those in config/environment.rb
# The production environment is meant for finished, "live" apps.
# Code is not reloaded between requests
config.cache_classes = true
# Full error reports are disabled and caching is turned on
config.action_controller.consider_all_reque... | Ruby |
# Settings specified here will take precedence over those in config/environment.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the webserver when you make code changes.
config.ca... | Ruby |
# Settings specified here will take precedence over those in config/environment.rb
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between... | Ruby |
# Be sure to restart your server when you modify this file
# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
r... | Ruby |
# Don't change this file!
# Configure your app in config/environment.rb and config/environments/*.rb
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
module Rails
class << self
def boot!
unless booted?
preinitialize
pick_boot.run
end
end
def booted?
... | Ruby |
ActionController::Routing::Routes.draw do |map|
# The priority is based upon order of creation: first created -> highest priority.
# Sample of regular route:
# map.connect 'products/:id', :controller => 'catalog', :action => 'view'
# Keep in mind you can assign values other than :controller and :action
# ... | Ruby |
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
end
| Ruby |
class WeeklyExcept < ActiveRecord::Base
establish_connection :weekly
validates_uniqueness_of :wid, :scope=>:weekly_id, :message => 'same wid'
end
| Ruby |
class Result < ActiveRecord::Base
belongs_to :work
belongs_to :scan
#评论倍值
E_C = 50
#收藏倍值
E_S = 100
#弹幕倍值
E_D = 0.5
def get_ranking_point
clicks_point = clicks.to_f * click_revised
comment_point = comments.to_f * comment_revised
format("%.2f", (clicks_point + comment_point + stow... | Ruby |
class WeeklyResult < ActiveRecord::Base
establish_connection :weekly
belongs_to :weekly
#nil = 'new'
#-1 = except
#>0
def last_score_rank
return -1 if wid == weekly.last.last.wid
last_weekly = weekly.last
if last_weekly
last_result = WeeklyResult.find_by_wid_and_weekly_id wid, last_weekly... | Ruby |
class Scan < ActiveRecord::Base
has_many :results, :dependent => :destroy
def self.search ac_types
require 'net/http/persistent'
pages = []
http = Net::HTTP::Persistent.new(nil, (PROXY ? URI.parse(PROXY) : nil))
http.connection_for(URI.parse('http://bilibili.us/'))
ac_types.each do |ac_type|
... | Ruby |
require 'rexml/document'
require 'net/http'
class FlashVar < ActiveRecord::Base
belongs_to :work
validates_uniqueness_of :vid, :scope=>:work_id, :message => 'same'
validates_presence_of :vid, :message => 'vid is null'
has_many :d_results
belongs_to :space_type
def add_result( scan = Scan.find(:first, :orde... | Ruby |
class Weekly < ActiveRecord::Base
establish_connection :weekly
has_many :weekly_results, :dependent => :destroy
belongs_to :last, :foreign_key => :parent_id, :class_name => 'Weekly'
def self.latest
find :first, :order => '"index" desc'
end
end
| Ruby |
class Author < ActiveRecord::Base
has_many :works
end
| Ruby |
class AcType < ActiveRecord::Base
has_many :works
has_many :scans
validates_uniqueness_of :name
end
| Ruby |
class Work < ActiveRecord::Base
belongs_to :ac_type
has_many :results
belongs_to :author
has_many :flash_vars, :conditions => "space_type_id is not null"
has_many :youku_and_tudou, :class_name => "FlashVar", :conditions => "space_type_id in (4,6)"
validates_uniqueness_of :wid, :message => 'wid same'
valid... | Ruby |
class SpaceType < ActiveRecord::Base
end
| Ruby |
class DResult < ActiveRecord::Base
belongs_to :scan
belongs_to :flash_var
validates_uniqueness_of :flash_var_id, :scope=>:scan_id, :message => 'same'
end
| Ruby |
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
protect_from_forgery # See ActionController::RequestForgeryPr... | Ruby |
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'tasks/rails'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/dbconsole'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/console'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/runner'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../../config/boot', __FILE__)
require 'commands/performance/benchmarker'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../../config/boot', __FILE__)
require 'commands/performance/benchmarker'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../../config/boot', __FILE__)
require 'commands/performance/profiler'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../../config/boot', __FILE__)
require 'commands/performance/profiler'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/plugin'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/destroy'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
require 'commands/about'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/dbconsole'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/runner'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/server'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/generate'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/console'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/destroy'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/generate'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/server'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
require 'commands/about'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/plugin'
| Ruby |
class AddStowToResults < ActiveRecord::Migration
def self.up
add_column :results, :stows, :integer
end
def self.down
remove_column :results, :stows
end
end
| Ruby |
class CreateResults < ActiveRecord::Migration
def self.up
create_table :results do |t|
t.integer :work_id
t.integer :scan_id
t.integer :clicks
t.integer :comments
end
end
def self.down
drop_table :results
end
end
| Ruby |
class CreateSpaceTypes < ActiveRecord::Migration
def self.up
create_table :space_types do |t|
t.string :name
t.string :code
end
SpaceType.create :name => 'sina', :code => 'vid'
SpaceType.create :name => 'bilibili', :code => 'avid'
SpaceType.create :name => 'other', :code => 'id'
Sp... | Ruby |
class AddColumnPicToWork < ActiveRecord::Migration
def self.up
add_column :works, :pic_path, :string
end
def self.down
remove_column :works, :pic_path
end
end
| Ruby |
class CreateScans < ActiveRecord::Migration
def self.up
create_table :scans do |t|
t.integer :ac_type_id
t.text :description
t.timestamps
end
end
def self.down
drop_table :scans
end
end
| Ruby |
class CreateAuthor < ActiveRecord::Migration
def self.up
create_table :authors do |t|
t.string :login_name
t.string :nick_name
end
end
def self.down
drop_table :authors
end
end
| Ruby |
class CreateFlashVars < ActiveRecord::Migration
def self.up
create_table :flash_vars do |t|
t.string :vid
t.integer :work_id
end
end
def self.down
drop_table :flash_vars
end
end
| Ruby |
class AddIndexToWorks < ActiveRecord::Migration
def self.up
add_index :works, :wid, :unique => true
end
def self.down
remove_index :works, :wid
end
end
| Ruby |
class AddCodeTypeToAcTypes < ActiveRecord::Migration
def self.up
add_column :ac_types, :code_type, :integer
AcType.all.each{|ac| ac.update_attribute :code_type, 0}
end
def self.down
remove_column :ac_types, :code_type
end
end
| Ruby |
class CreateWorks < ActiveRecord::Migration
def self.up
create_table :works do |t|
t.string :name
t.datetime :cdate
t.integer :wid
t.integer :ac_type_id
t.integer :author_id
t.string :author_name
t.integer :status, :default => 1 #1-正常 2-除外
t.integer :part_coun... | Ruby |
class AddColumnDanmuToResult < ActiveRecord::Migration
def self.up
add_column :results, :danmu, :integer
end
def self.down
remove_column :results, :danmu
end
end
| Ruby |
class CreateDResults < ActiveRecord::Migration
def self.up
create_table :d_results do |t|
t.integer :scan_id
t.integer :flash_var_id
t.integer :d_count
end
end
def self.down
drop_table :d_results
end
end
| Ruby |
class CreateAcTypes < ActiveRecord::Migration
def self.up
create_table :ac_types do |t|
t.string :name
t.string :page_name
t.string :page_code
end
end
def self.down
drop_table :ac_types
end
end
| Ruby |
class AddMidToAuthors < ActiveRecord::Migration
def self.up
add_column :authors, :mid, :integer
end
def self.down
remove_column :authors, :mid
end
end
| Ruby |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
# Major.create(:name... | Ruby |
#pa, id
#list1 => true list1_count => 30
#list2 => true list2_count => 120
namespace :bld do
desc "Export to image from database"
task :export_to_img => :environment do
require 'lib/tasks/bili_ranking_image.rb'
pa = "#{BILI_PRO_PATH}#{ENV['pa']}\\"
list1 = ENV['list1'] || true
list1 = false if list1... | Ruby |
namespace :acr do
desc "Video auto copy"
task :avi_copy => :environment do
require 'csv'
pa = "#{BILI_PRO_PATH}#{ENV['pa']}\\"
csv_file = File.open "#{pa}_list.csv"
csv_data = CSV::IOReader.new(csv_file)
list_count = (ENV['list_count'] || 30).to_i
data = []
csv_data.each do |row|
d... | Ruby |
#name, wid, pa
namespace :bld do
desc "Import CSV to database"
task :save_history_data => :environment do
require 'csv'
pa = "#{BILI_PRO_PATH}#{ENV['pa']}\\"
csv_file = File.open "#{pa}_list.csv"
date_now = Time.now
puts "reading csv file..."
csv_data = CSV::IOReader.new(csv_file)
data ... | Ruby |
namespace :bilibiliranking do
desc "bilibili ranking example pickup"
task :pickup => :environment do
require 'lib/tasks/vegas_video_maker.rb'
require 'lib/tasks/bili_ranking_maker.rb'
include VegasVideoMaker
BRM.create({:path => "#{BILI_PRO_PATH}#{ENV['pa']}\\"}) do |vvm|
vvm.pickup
end
... | Ruby |
namespace :bilibiliranking do
desc "bilibili ranking example over"
task :over => :environment do
require 'lib/tasks/vegas_video_maker.rb'
require 'lib/tasks/bili_ranking_maker.rb'
include VegasVideoMaker
BRM.create({:path => "#{BILI_PRO_PATH}#{ENV['pa']}\\"}) do |vvm|
vvm.play_bgm("bilibili.mp... | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.