code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
#
# << Haru Free PDF Library 2.0.2 >> -- ttfont_demo.rb
#
# http://libharu.org/
#
# Copyright (c) 1999-2006 Takeshi Kanno
#
# Permission to use, copy, modify, distribute and sell this software
# and its documentation for any purpose is hereby granted without fee,
# provided that the above copyright notice appe... | Ruby |
#
# << Haru Free PDF Library 2.0.0 >> -- font_example.rb
#
# Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp>
#
# Permission to use, copy, modify, distribute and sell this software
# and its documentation for any purpose is hereby granted without fee,
# provided that the above copyright noti... | Ruby |
#
# << Haru Free PDF Library 2.0.0 >> -- encryption.rb
#
# Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp>
#
# Permission to use, copy, modify, distribute and sell this software
# and its documentation for any purpose is hereby granted without fee,
# provided that the above copyright notice... | Ruby |
#
# << Haru Free PDF Library 2.0.0 >> -- demo.rb
#
# Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp>
#
# Permission to use, copy, modify, distribute and sell this software
# and its documentation for any purpose is hereby granted without fee,
# provided that the above copyright notice appea... | Ruby |
#
# << Haru Free PDF Library 2.0.6 >> -- slideshow_demo.rb
#
# http://libharu.org/
#
# Copyright (c) 1999-2006 Takeshi Kanno
#
# Permission to use, copy, modify, distribute and sell this software
# and its documentation for any purpose is hereby granted without fee,
# provided that the above copyright notice a... | Ruby |
#
# << Haru Free PDF Library 2.0.2 >> -- arc_demo.rb
#
# http://libharu.org/
#
# Copyright (c) 1999-2006 Takeshi Kanno
#
# Permission to use, copy, modify, distribute and sell this software
# and its documentation for any purpose is hereby granted without fee,
# provided that the above copyright notice appear ... | Ruby |
require 'mkmf'
$CPPFLAGS = $CPPFLAGS + " -I../../include"
$LDFLAGS = $LDFLAGS + " -L../../"
$LIBS = $LIBS + " -lhpdf -lpng -lz"
create_makefile 'hpdf'
| Ruby |
#!/usr/bin/env ruby
def fix_require(l)
l = l.gsub('rb_require(', '// rb_require(')
l = l.gsub('rb_require_wrapitk(', 'rb_require(')
return l
end
input = File.new(ARGV[0])
output = File.new(ARGV[1], "w")
input.each_line {|line| output.puts( fix_require( line ) )}
input.close
output.close
| Ruby |
#!/usr/bin/env ruby
def fix_require(l)
l = l.gsub('rb_require(', '// rb_require(')
l = l.gsub('rb_require_wrapitk(', 'rb_require(')
return l
end
input = File.new(ARGV[0])
output = File.new(ARGV[1], "w")
input.each_line {|line| output.puts( fix_require( line ) )}
input.close
output.close
| Ruby |
#!/usr/bin/env ruby
def fix_require(l)
l = l.gsub('rb_require(', '// rb_require(')
l = l.gsub('rb_require_wrapitk(', 'rb_require(')
return l
end
input = File.new(ARGV[0])
output = File.new(ARGV[1], "w")
input.each_line {|line| output.puts( fix_require( line ) )}
input.close
output.close
| Ruby |
#!/usr/bin/env ruby
def fix_require(l)
l = l.gsub('rb_require(', '// rb_require(')
l = l.gsub('rb_require_wrapitk(', 'rb_require(')
return l
end
input = File.new(ARGV[0])
output = File.new(ARGV[1], "w")
input.each_line {|line| output.puts( fix_require( line ) )}
input.close
output.close
| Ruby |
#!/usr/bin/env ruby
def fix_require(l)
l = l.gsub('rb_require(', '// rb_require(')
l = l.gsub('rb_require_wrapitk(', 'rb_require(')
return l
end
input = File.new(ARGV[0])
output = File.new(ARGV[1], "w")
input.each_line {|line| output.puts( fix_require( line ) )}
input.close
output.close
| Ruby |
#!/usr/bin/env ruby
def fix_require(l)
l = l.gsub('rb_require(', '// rb_require(')
l = l.gsub('rb_require_wrapitk(', 'rb_require(')
return l
end
input = File.new(ARGV[0])
output = File.new(ARGV[1], "w")
input.each_line {|line| output.puts( fix_require( line ) )}
input.close
output.close
| 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.2' unless defined? RAILS_GEM_VERSION
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
... | 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|
map.resources :elements, :active_scaffold => true
# 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 a... | Ruby |
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
end
| Ruby |
module ElementsHelper
def taggings_column(record)
label = []
record.taggings.each { |t| label << t.tag.name }
label.join(" ")
end
def description_column(record)
truncate(record.description, :length => 128)
end
def description_show_column(record)
record.description
end
end
| Ruby |
module TagHelper
end
| Ruby |
module HomeHelper
end
| Ruby |
module AccountHelper
end | Ruby |
require 'digest/sha1'
class User < ActiveRecord::Base
# Virtual attribute for the unencrypted password
attr_accessor :password
validates_presence_of :login, :email
validates_presence_of :password, :if => :password_required?
validates_presence_of :password_confirmation, :if ... | Ruby |
class Link < ActiveRecord::Base
belongs_to :itself, :foreign_key => :element_id, :class_name => "Element"
belongs_to :otherselfs, :foreign_key => :related_id, :class_name => "Element"
TYPE_STRING = [['含む(1->2)', 1],
['含む(2->1)', 2],
['同じ', 3],
... | Ruby |
class HomeController < ApplicationController
def index
end
end
| Ruby |
class TagController < ApplicationController
active_scaffold :tag do |config|
config.list.per_page = 10
config.list.sorting = {:name => :asc}
config.label = "タグリスト"
config.columns = [:name]
config.actions.exclude :show, :search
end
layout "activescaffold"
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 |
class AccountController < ApplicationController
# Be sure to include AuthenticationSystem in Application Controller instead
include AuthenticatedSystem
# If you want "remember me" functionality, add this before_filter to Application Controller
before_filter :login_from_cookie
# say something nice, you goof! ... | Ruby |
class ElementsController < ApplicationController
active_scaffold :element do |config|
config.list.per_page = 10
config.list.sorting = {:id => :asc}
config.label = "要件リスト"
config.columns = [:taggings, :title, :description]
config.columns[:title].label = "タイトル"
config.columns[:title].description... | 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.dirname(__FILE__) + '/../config/boot'
require 'commands/dbconsole'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/console'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/runner'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/benchmarker'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/benchmarker'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/profiler'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/profiler'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/plugin'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/destroy'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
require 'commands/about' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/dbconsole'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/runner'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/server'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/generate'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/console'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/destroy'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/generate'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/server'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
require 'commands/about' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/plugin'
| Ruby |
class ActsAsTaggableMigration < ActiveRecord::Migration
def self.up
#Table for your Tags
create_table :tags do |t|
t.column :name, :string
end
create_table :taggings do |t|
t.column :tag_id, :integer
#id of tagged object
t.column :taggable_id, :integer
#type of object ta... | Ruby |
class AddVersions < ActiveRecord::Migration
def self.up
Element.create_versioned_table
Element.transaction do
Element.find(:all).each do |e|
e.version = 1
e.save_version
end
end
end
def self.down
Element.drop_versioned_table
end
end
| Ruby |
class CreateElements < ActiveRecord::Migration
def self.up
create_table :elements do |t|
t.string :title
t.text :description
t.timestamps
end
end
def self.down
drop_table :elements
end
end
| Ruby |
class CreateLinks < ActiveRecord::Migration
def self.up
create_table :links do |t|
t.integer :element_id
t.integer :related_id
t.integer :type
t.timestamps
end
end
def self.down
drop_table :links
end
end
| Ruby |
class AddDeleteFlag < ActiveRecord::Migration
def self.up
add_column :elements, :deleted_at, :datetime
add_column :links, :deleted_at, :datetime
end
def self.down
remove_column :elements, :deleted_at
remove_column :links, :deleted_at
end
end
| Ruby |
class CreateUsers < ActiveRecord::Migration
def self.up
create_table "users", :force => true do |t|
t.column :login, :string
t.column :email, :string
t.column :crypted_password, :string, :limit => 40
t.column :salt, :str... | Ruby |
module AuthenticatedSystem
protected
# Returns true or false if the user is logged in.
# Preloads @current_user with the user model if they're logged in.
def logged_in?
current_user != :false
end
# Accesses the current user from the session.
def current_user
@current_user ||= ... | Ruby |
module AuthenticatedTestHelper
# Sets the current user in the session from the user fixtures.
def login_as(user)
@request.session[:user] = user ? users(user).id : nil
end
def content_type(type)
@request.env['Content-Type'] = type
end
def accept(accept)
@request.env["HTTP_ACCEPT"] = accept
en... | Ruby |
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'
class ActiveSupport::TestCase
# Transactional fixtures accelerate your tests by wrapping each test method
# in a transaction that's rolled back on completion. This ensures that the
# test da... | Ruby |
require 'sinatra/activerecord/rake'
require './main' | Ruby |
source :gemcutter
gem 'sinatra', :require => 'sinatra/base'
gem 'thin', '~> 1.3'
gem 'pg'
gem 'sinatra-activerecord'
gem 'google-api-client', '>= 0.4.4', :require => 'google/api_client'
group :development do
gem 'rake'
gem 'sqlite3-ruby'
end
| Ruby |
class CreateUsers < ActiveRecord::Migration
def up
create_table :users do |t|
t.string :profile_id
t.string :email
t.string :refresh_token
end
add_index :users, :profile_id
end
def down
drop_table :users
end
end
| Ruby |
# Copyright (C) 2012 Google Inc.
#
# 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 agreed to in writ... | Ruby |
require 'sinatra.rb'
# Sinatra defines #set at the top level as a way to set application configuration
set :run, false
set :env, (ENV['RACK_ENV'] ? ENV['RACK_ENV'].to_sym : :development)
require './main'
run Sinatra::Application | Ruby |
# $ext_path: This should be the path of where the ExtJS SDK is installed
# Generally this will be in a lib/extjs folder in your applications root
# <root>/lib/extjs
$ext_path = "../../"
# sass_path: the directory your Sass files are in. THIS file should also be in the Sass folder
# Generally this will be in a resource... | Ruby |
# include the utils rb file which has extra functionality for the ext theme
dir = File.dirname(__FILE__)
require File.join(dir, 'lib', 'utils.rb')
# register ext4 as a compass framework
Compass::Frameworks.register 'ext4', dir | Ruby |
# $ext_path: This should be the path of the Ext JS SDK relative to this file
$ext_path = "../../extjs"
# sass_path: the directory your Sass files are in. THIS file should also be in the Sass folder
# Generally this will be in a resources/sass folder
# <root>/resources/sass
sass_path = File.dirname(__FILE__)
# css_pat... | Ruby |
# Compass configurations
sass_path = File.dirname(__FILE__)
css_path = File.join(sass_path, "..", "css")
# Require any additional compass plugins here.
images_dir = File.join(sass_path, "..", "img")
output_style = :expanded
environment = :production | Ruby |
module ExtJS4
module SassExtensions
module Functions
module Utils
def parsebox(list, n)
assert_type n, :Number
if !n.int?
raise ArgumentError.new("List index #{n} must be an integer")
elsif n.to_i < 1
raise ArgumentError.new("List index #{n} must... | Ruby |
module UsersHelper
end
| Ruby |
module ApplicationHelper
end
| Ruby |
module QuestionsHelper
end
| Ruby |
module TakequizHelper
end
| Ruby |
module AnswersHelper
end
| Ruby |
module ResponsesHelper
end
| Ruby |
module CreatequizHelper
end
| Ruby |
require 'digest/sha2'
class User < ActiveRecord::Base
validates :name, :presence => true, :uniqueness => true
validates :password, :confirmation => true
attr_accessor :password_confirmation
attr_reader :password
validate :password_must_be_present
has_many :quizzes
def User.authenticate(name, password)
... | Ruby |
class Response < ActiveRecord::Base
belongs_to :user
belongs_to :quiz
end
| Ruby |
class Answer < ActiveRecord::Base
belongs_to :question
serialize :body
validates :body, :presence => true
validates :score, :presence => true, :numericality => true
end
| Ruby |
class Quiz < ActiveRecord::Base
has_many :questions
belongs_to :user
serialize :scoring
validates :title, :presence => true
validates :description, :presence => true
validates :scoring, :presence => true, :format => /^[0-9]+[ ].+$/
end
| Ruby |
class Question < ActiveRecord::Base
belongs_to :quiz
has_many :answers
serialize :answerold
validates :title, :presence => true
validates :body, :presence => true
end
| Ruby |
class CreatequizController < ApplicationController
def newquiz
@quiz = Quiz.new
@title = params[:title]
@description = params[:description]
@scoring = params[:scoring]
@isquiz = params[:isquiz]
@fail= params[:fail]
end
def newquestion
@question = Question.new
@quiz = Quiz.find(s... | Ruby |
class ApplicationController < ActionController::Base
protect_from_forgery
end
| Ruby |
class QuestionsController < ApplicationController
end
| Ruby |
class TakequizController < ApplicationController
def question
@quiz =Quiz.find(params[:quiz_id])
@questions = @quiz.questions.map {|q| q.id}
session[:q] = @questions
session[:quiz] = @quiz.id
session[:score] = 0
redirect_to :action => :ask
end
def ask
@quiz = Quiz.find(session[:quiz])... | Ruby |
class AnswersController < ApplicationController
# GET /answers
# GET /answers.xml
def index
@answers = Answer.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @answers }
end
end
# GET /answers/1
# GET /answers/1.xml
def show
@answer = Answe... | Ruby |
class UserController < ApplicationController
def login
end
def choose
if !session[:user_id]
redirect_to(:action => :login)
end
@users = User.all
end
def new
@user = User.new
end
def create
@user = User.new(params[:user])
if @user.save
session[:user_id] = @user.id... | Ruby |
source 'http://rubygems.org'
gem 'rails', '3.0.3'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3-ruby', :require => 'sqlite3'
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger (ruby-debug for Ruby 1.8.... | Ruby |
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
#
# Note: You'll currently still have to declare fixtures explicitly in integrati... | 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 |
class CreateAnswers < ActiveRecord::Migration
def self.up
create_table :answers do |t|
t.string :anstype
t.text :body
t.integer :score
t.integer :spot
t.references :question
t.timestamps
end
end
def self.down
drop_table :answers
end
end
| Ruby |
class CreateResponses < ActiveRecord::Migration
def self.up
create_table :responses do |t|
t.integer :hashed_question_id
t.integer :quiz_id
t.integer :user_id
t.text :answers
t.boolean :complete
t.timestamps
end
end
def self.down
drop_table :responses
end
end
| Ruby |
class CreateQuestions < ActiveRecord::Migration
def self.up
create_table :questions do |t|
t.string :anstype
t.string :title
t.text :body
t.integer :spot
t.references :quiz
t.timestamps
end
end
def self.down
drop_table :questions
end
end
| Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.