code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
=begin
= File
reference.rb
= Info
Origami is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Origami is distributed in the h... | Ruby |
=begin
= File
name.rb
= Info
This file is part of Origami, PDF manipulation framework for Ruby
Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org>
All right reserved.
Origami is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as... | Ruby |
=begin
= File
webcapture.rb
= Info
Origami is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Origami is distributed in the ... | Ruby |
=begin
= File
metadata.rb
= Info
This file is part of Origami, PDF manipulation framework for Ruby
Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org>
All right reserved.
Origami is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public Licens... | Ruby |
=begin
= File
signature.rb
= Info
Origami is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Origami is distributed in the h... | Ruby |
=begin
= File
javascript.rb
= Info
This file is part of Origami, PDF manipulation framework for Ruby
Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org>
All right reserved.
Origami is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public Li... | Ruby |
=begin
= File
export.rb
= Info
This file is part of Origami, PDF manipulation framework for Ruby
Copyright (C) 2010 Guillaume DelugrÈ <guillaume@security-labs.org>
All right reserved.
Origami is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License ... | Ruby |
=begin
= File
array.rb
= Info
This file is part of Origami, PDF manipulation framework for Ruby
Copyright (C) 2010 Guillaume DelugrÈ <guillaume@security-labs.org>
All right reserved.
Origami is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License a... | Ruby |
=begin
= File
filters/jpx.rb
= Info
This file is part of Origami, PDF manipulation framework for Ruby
Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org>
All right reserved.
Origami is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public Lic... | Ruby |
=begin
= File
filters/lzw.rb
= Info
This file is part of Origami, PDF manipulation framework for Ruby
Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org>
All right reserved.
Origami is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public Lic... | Ruby |
=begin
= File
filters/dct.rb
= Info
This file is part of Origami, PDF manipulation framework for Ruby
Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org>
All right reserved.
Origami is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public Lic... | Ruby |
=begin
= File
filters/crypt.rb
= Info
This file is part of Origami, PDF manipulation framework for Ruby
Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org>
All right reserved.
Origami is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public L... | Ruby |
=begin
= File
filters/runlength.rb
= Info
This file is part of Origami, PDF manipulation framework for Ruby
Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org>
All right reserved.
Origami is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Publ... | Ruby |
=begin
= File
filters/predictors.rb
= Info
This file is part of Origami, PDF manipulation framework for Ruby
Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org>
All right reserved.
Origami is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Pub... | Ruby |
=begin
= File
filters/flate.rb
= Info
This file is part of Origami, PDF manipulation framework for Ruby
Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org>
All right reserved.
Origami is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public L... | Ruby |
=begin
= File
filters/jbig2.rb
= Info
This file is part of Origami, PDF manipulation framework for Ruby
Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org>
All right reserved.
Origami is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public L... | Ruby |
=begin
= File
filters/ascii.rb
= Info
This file is part of Origami, PDF manipulation framework for Ruby
Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org>
All right reserved.
Origami is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public L... | Ruby |
=begin
= File
filters/ccitt.rb
= Info
This file is part of Origami, PDF manipulation framework for Ruby
Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org>
All right reserved.
Origami is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public L... | Ruby |
=begin
= File
file.rb
= Info
This file is part of Origami, PDF manipulation framework for Ruby
Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org>
All right reserved.
Origami is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as... | Ruby |
=begin
= File
boolean.rb
= Info
This file is part of Origami, PDF manipulation framework for Ruby
Copyright (C) 2010 Guillaume DelugrÈ <guillaume@security-labs.org>
All right reserved.
Origami is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License... | Ruby |
=begin
= File
stream.rb
= Info
Origami is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Origami is distributed in the hope... | Ruby |
=begin
= File
parsers/pdf.rb
= Info
This file is part of Origami, PDF manipulation framework for Ruby
Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org>
All right reserved.
Origami is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public Lic... | Ruby |
=begin
= File
parsers/linear.rb
= Info
Origami is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Origami is distributed in ... | Ruby |
=begin
= File
parsers/ppklite.rb
= Info
Origami is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Origami is distributed in... | Ruby |
=begin
= File
parsers/fdf.rb
= Info
Origami is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Origami is distributed in the... | Ruby |
=begin
= File
page.rb
= Info
Origami is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Origami is distributed in the hope t... | Ruby |
=begin
= File
xreftable.rb
= Info
Origami is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Origami is distributed in the h... | Ruby |
=begin
= File
object.rb
= Info
Origami is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Origami is distributed in the hope... | Ruby |
# coding: utf-8
# Title: LightPack API wrapper for Ruby
# Author: Mikhail S. Pobolovets
# License: GPL v3
# Date: 2011/08/15
# API Version: 5.5
require 'socket'
class LightPack
include Socket::Constants
# host = '127.0.0.1' # The remote host
# port = 3636 ... | Ruby |
# Copyright 2008-2009 Nokia Siemens Networks Oyj
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or... | Ruby |
#!/usr/bin/env ruby
class ExampleRemoteLibrary
def count_items_in_directory(path)
Dir.entries(path).find_all{|i| not i.match('^\.')}.length
end
def strings_should_be_equal(str1, str2)
puts "Comparing '#{str1}' to '#{str2}'"
if str1 != str2
raise RuntimeError, "Given strings are not equal"
... | Ruby |
Bili::Application.configure do
# Settings specified here will take precedence over those in config/application.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
... | Ruby |
Bili::Application.configure do
# Settings specified here will take precedence over those in config/application.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 webserve... | Ruby |
Bili::Application.configure do
# Settings specified here will take precedence over those in config/application.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 sui... | Ruby |
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
Bili::Application.initialize!
| Ruby |
require 'rubygems'
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
| Ruby |
require File.expand_path('../boot', __FILE__)
require 'rails/all'
Bundler.require(:default, Rails.env) if defined?(Bundler)
module Bili
class Application < Rails::Application
config.time_zone = 'Beijing'
config.encoding = "utf-8"
config.filter_parameters += [:password]
end
end
| Ruby |
Bili::Application.routes.draw do
get "pickup/index"
#get "index/index"
# The priority is based upon order of creation:
# first created -> highest priority.
# Sample of regular route:
# match 'products/:id' => 'catalog#view'
# Keep in mind you can assign values other than :controller and :action
mat... | Ruby |
module ApplicationHelper
include BilibiliApi
#options: name, part
def bili_video_link wid, options={}
name = options[:name]
part = options[:part]
url = %[http://#{BILI_PATH}/video/av#{wid}/#{"index_#{part}.html" if part.to_i > 1}]
link_to (name ? h(name) : "av#{wid}"), url, :target => "_blank... | Ruby |
module IndexHelper
end
| Ruby |
class Key < ActiveRecord::Base
establish_connection :user
has_many :key_users
end
| Ruby |
class Result < ActiveRecord::Base
belongs_to :work
belongs_to :weekly
def self.rule version = RULE
eval("Rule::R#{(version * 10).to_i}")
end
#是否长期
def is_changqi?
if weekly_id
Result.count(:include => :weekly,
:conditions => ["rank <= weeklies.rank_from and results.work_id = ? and we... | Ruby |
class OriWork < ActiveRecord::Base
establish_connection :bilibili
set_table_name :works
end
| Ruby |
class App < ActiveRecord::Base
establish_connection :user
end
| Ruby |
class Rule::R10 < Result
E_S = 100
def self.version
self.to_s.split('::R').last.to_f / 10
end
def get_ranking_point
self[:score] = click.to_f / part + stow * stow_revised - [yb * 100 + tj, 20000].min
end
def point
self[:score] || get_ranking_point
end
def self.get_stow_revised stow... | Ruby |
class Rule::R11 < Rule::R10
E_S = 100
def get_ranking_point
self[:score] = click.to_f / part + stow * stow_revised + tj_point
end
def tj_point
if weekly_id
self.class.tj_point yb, tj, click, work_id, weekly_id
else
self.class.tj_point yb, tj, click, work_id, Weekly.last.id + 1
end... | Ruby |
class Pickup < ActiveRecord::Base
end
| Ruby |
class Except < ActiveRecord::Base
validates_uniqueness_of :avid, :message => 'same'
def self.all_avid
all.collect(&:avid)
end
end
| Ruby |
class KeyUser < ActiveRecord::Base
establish_connection :user
belongs_to :key
validates_uniqueness_of :uname, :scope=>:key_id, :message => 'same'
validates_presence_of :uname, :message => 'uname is null'
end
| Ruby |
class Weekly < ActiveRecord::Base
belongs_to :last, :foreign_key => :parent_id, :class_name => 'Weekly'
def self.latest
find :first, :conditions => "wid is not null", :order => '"index" desc'
end
def set_name edate
update_attribute :name, %[#{edate.year % 2000}年#{edate.month}月第#{edate.day / 7 + 1}周]
... | Ruby |
class OriResult < ActiveRecord::Base
establish_connection :bilibili
set_table_name :results
belongs_to :work, :class_name => "OriWork"
belongs_to :scan, :class_name => "OriScan"
end
| Ruby |
class Work < ActiveRecord::Base
end
| Ruby |
class OriScan < ActiveRecord::Base
establish_connection :bilibili
set_table_name :scans
def self.weekly_last_id
YAML.load(open(File.join "#{Rails.root}/config/last.yml")) rescue 0
end
end
| Ruby |
class ManaController < ApplicationController
before_filter :correct_bili_name?, :limit_bili_users
layout "need_bili_name"
def index
end
def temp_data
YAML::add_private_type(Result.rule.to_s)
YAML::add_private_type(Work.to_s)
@stats = YAML.load(open("#{Rails.root}/config/_list.yml"))
@stats.... | Ruby |
class ResultController < ApplicationController
def one
result = Result.find_by_score_rank_and_weekly_id params[:rank], params[:id]
work =Work.find_by_wid result.wid, :select => "wid, cdate, pic_path"
last_score_rank = result.last_score_rank
is_changqi = result.is_changqi?
respond_to do |format|
... | Ruby |
class ApplicationController < ActionController::Base
protect_from_forgery
include BilibiliApi
end
| Ruby |
class IndexController < ApplicationController
def logout
super
end
end
| 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.expand_path('../config/application', __FILE__)
require 'rake'
Bili::Application.load_tasks
| Ruby |
source 'http://rubygems.org'
gem 'rails', '3.0.9'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'pg'
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)... | Ruby |
class CreateWeeklies < ActiveRecord::Migration
def self.up
create_table :weeklies do |t|
t.integer :wid
t.string :name
t.integer :parent_id
t.integer :index
t.integer :rank_from
t.float :rule
end
end
def self.down
drop_table :weeklies
end
end
| Ruby |
class CreateWorks < ActiveRecord::Migration
def self.up
create_table :works do |t|
t.integer :wid
t.datetime :cdate
t.string :author
end
end
def self.down
drop_table :works
end
end
| Ruby |
class CreatePickups < ActiveRecord::Migration
def self.up
create_table :pickups do |t|
t.integer :wid
t.integer :weekly_id
end
end
def self.down
drop_table :pickups
end
end
| Ruby |
class AddPtypeToPickup < ActiveRecord::Migration
def self.up
add_column :pickups, :ptype, :integer
end
def self.down
remove_column :pickups, :ptype
end
end
| Ruby |
class CreateExcepts < ActiveRecord::Migration
def self.up
create_table :excepts do |t|
t.integer :avid
end
end
def self.down
drop_table :excepts
end
end
| Ruby |
class CreateResults < ActiveRecord::Migration
def self.up
create_table :results do |t|
t.integer :work_id
t.integer :weekly_id
t.string :name
t.integer :click
t.integer :stow
t.integer :yb
t.integer :tj
t.integer :part
t.integer :rank
end
end
def self... | 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' }])
# Mayor.create(:name =>... | Ruby |
#name, wid, pa
namespace :bld do
desc "Import scan result to database"
task :save => :environment do
date_now = Time.now
pa = ENV['pa'] ? "#{BILI_PRO_PATH}#{ENV['pa']}/" : nil
id1 = ENV['id1'] || (YAML.load(open(File.join "#{Rails.root}/config/last.yml")) rescue 0)
id2 = ENV['id2'] || OriScan.last.... | Ruby |
#id1 前,default=0; id2 后,default=last.id; pa, 必须有except.yml
namespace :bld do
desc "Export to yaml"
task :export => :environment do
puts time = Time.now
pa = ENV['pa'] ? "#{BILI_PRO_PATH}#{ENV['pa']}/" : nil
id1 = ENV['id1'] || (YAML.load(open(File.join "#{Rails.root}/config/last.yml")) rescue 0)
id2... | Ruby |
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run Bili::Application
| Ruby |
Bilinote::Application.configure do
# Settings specified here will take precedence over those in config/application.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 o... | Ruby |
Bilinote::Application.configure do
# Settings specified here will take precedence over those in config/application.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 webs... | Ruby |
Bilinote::Application.configure do
# Settings specified here will take precedence over those in config/application.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... | Ruby |
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
Bilinote::Application.initialize!
| Ruby |
require 'rubygems'
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
| Ruby |
require File.expand_path('../boot', __FILE__)
require 'rails/all'
# If you have a Gemfile, require the gems listed there, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env) if defined?(Bundler)
module Bilinote
class Application < Rails::Application
... | Ruby |
module ApplicationHelper
end
| Ruby |
module IndexHelper
end
| Ruby |
module ManaHelper
end
| Ruby |
module DailyTypesHelper
end
| Ruby |
class Key < ActiveRecord::Base
establish_connection :user
has_many :key_users
end
| Ruby |
class DailyType < ActiveRecord::Base
end
| Ruby |
class NoteDate < ActiveRecord::Base
has_many :dailies
end
| Ruby |
class App < ActiveRecord::Base
establish_connection :user
end
| Ruby |
class OperateLog < ActiveRecord::Base
end
| Ruby |
class KeyUser < ActiveRecord::Base
establish_connection :user
belongs_to :key
end
| Ruby |
class Daily < ActiveRecord::Base
has_and_belongs_to_many :daily_types
end
| Ruby |
class ManaController < ApplicationController
before_filter :correct_bili_name?, :limit_bili_users
layout "need_bili_name"
def mana_index
end
def logout
super
end
end
| Ruby |
class DailyTypesController < ManaController
def new
@daily_type = DailyType.new
render :action => 'edit'
end
def edit
@daily_type = DailyType.find params[:id]
end
def show
redirect_to :action => :index
end
def index
@daily_types = DailyType.all
end
def create
daily... | Ruby |
class ApplicationController < ActionController::Base
protect_from_forgery
include BilibiliApi
end
| Ruby |
class IndexController < ApplicationController
def index
now = Time.zone.now
@note = NoteDate.find_or_create_by_year_and_month now.year, now.month
@dailies = Daily.find_all_by_note_date_id @note.id, :include => :daily_types,
:conditions => {:status => 1}, :orde... | 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.expand_path('../config/application', __FILE__)
require 'rake'
Bilinote::Application.load_tasks
| Ruby |
source 'http://rubygems.org'
gem 'rails', '3.0.6'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'pg'
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)... | Ruby |
class CreateDailies < ActiveRecord::Migration
def self.up
create_table :dailies do |t|
t.integer :day
t.string :name
t.text :content
t.string :url
t.string :img
t.string :uname
t.integer :status, :default => 0
t.integer :daily_type_id
t.integer :note_date_id
... | Ruby |
class CreateOperateLogs < ActiveRecord::Migration
def self.up
create_table :operate_logs do |t|
t.integer :daily_id
t.string :uname
t.integer :status_before
t.integer :status_after
t.timestamps
end
end
def self.down
drop_table :operate_logs
end
end
| Ruby |
class CreateDailyTypes < ActiveRecord::Migration
def self.up
create_table :daily_types do |t|
t.string :name
end
create_table :daily_types_dailies, :id => false do |t|
t.integer :daily_type_id
t.integer :daily_id
end
end
def self.down
drop_table :daily_types
drop_table ... | Ruby |
class CreateNoteDates < ActiveRecord::Migration
def self.up
create_table :note_dates do |t|
t.integer :year
t.integer :month
end
end
def self.down
drop_table :note_dates
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' }])
# Mayor.create(:name =>... | Ruby |
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run Bilinote::Application
| Ruby |
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
# Number to Currency with Cents
def number_to_currency_with_cents(number, options = {})
options = options.stringify_keys
precision = options.delete('precision') { 2 }
unit = options.de... | Ruby |
module BundlesHelper
end
| Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.