code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
#
# jruby examples for jas.
# $Id$
#
require "examples/jas"
# module example
p = PolyRing.new(QQ(),"(u,v,l)", PolyRing.lex);
#r = CommutativeModule.new( "Rat(u,v,l) L", nil, 4 );
r = CommutativeModule.new( "", p, 4 );
puts "Module: " + str(r);
puts;
G = r.gens();
puts "gens() = " + str( G.map { |e| str(e) }.join(",... | Ruby |
#
# jruby examples for jas.
# $Id$
#
#load "examples/jas.rb"
require "examples/jas"
# non-commutative polynomial examples: solvable polynomials example
r = WordPolyRing.new(QQ(),"a,b,e1,e2,e3");
puts "WordPolyRing: " + str(r);
puts;
one,a,b,e1,e2,e3 = r.gens();
puts "one = " + str(one);
puts "a = " + str(a);
puts "... | Ruby |
#
# jruby examples for jas.
# $Id$
#
require "examples/jas"
#startLog();
# polynomial examples: factorization over Z_p
#r = PolyRing.new( GF(19), "x", PolyRing.lex );
r = PolyRing.new( GF(1152921504606846883), "x", PolyRing.lex );
puts "Ring: " + str(r);
puts
#one,x = r.gens();
#f = x**4 - 1;
#f = x**3 + 1;
f = ... | Ruby |
#
# jruby examples for jas.
# $Id$
#
#load "examples/jas.rb"
require "examples/jas"
# trinks 6/7 example
#r = Ring.new( "Mod 19 (B,S,T,Z,P,W) L" );
#r = Ring.new( "Mod 1152921504606846883 (B,S,T,Z,P,W) L" ); # 2^60-93
#r = Ring.new( "Quat(B,S,T,Z,P,W) L" );
#r = Ring.new( "Z(B,S,T,Z,P,W) L" );
#r = Ring.new( "C(B,S... | Ruby |
#
# jruby examples for jas.
# $Id$
#
#load "examples/jas.rb"
require "examples/jas"
# trinks 6/7 example
# QQ = rational numbers, ZZ = integers, CC = complex rational numbers, GF = finite field
#r = PolyRing.new( GF(19),"B,S,T,Z,P,W", PolyRing.lex);
#r = PolyRing.new( GF(1152921504606846883),"B,S,T,Z,P,W", PolyRing... | Ruby |
#
# jruby examples for jas.
# $Id$
#
require "examples/jas"
# example for prime numbers
#
pl = PrimeList.new(PrimeList::Range.small);
puts "pl: " + str(pl);
puts;
pp = "";
for i in 0..pl.size()+10 do
pp = pp + " " + str(pl.get(i))
end
puts "pp: " + pp;
puts;
pl = PrimeList.new(PrimeList::Range.low);
puts "p... | Ruby |
#
# jruby examples for jas.
# $Id$
#
require "examples/jas"
# U(sl_2) example
rs = """
# solvable polynomials, U(sl_2):
Rat(e,f,h) G
RelationTable
(
( f ), ( e ), ( e f - h ),
( h ), ( e ), ( e h + 2 e ),
( h ), ( f ), ( f h - 2 f )
)
""";
r = SolvableRing.new( rs );
puts "SolvableRing: " + str(r);
puts;
ps =... | Ruby |
#
# jruby examples for jas.
# $Id$
#
require "examples/jas"
#startLog();
# polynomial examples: factorization over Q(sqrt(2))(x)(sqrt(x))[y]
Q = PolyRing.new(QQ(),"w2",PolyRing.lex);
puts "Q = " + str(Q);
e,a = Q.gens();
#puts "e = " + str(e);
puts "a = " + str(a);
root = a**2 - 2;
puts "root = " + st... | Ruby |
#
# jruby examples for jas.
# $Id$
#
require "examples/jas"
#startLog();
# polynomial examples: factorization over Z_p
p = 5;
cr = PolyRing.new( GF(p), "u", PolyRing.lex );
puts "Ring: " + str(cr);
puts
#one,u = r.gens();
fu = (u**2+u+1)**p;
puts "fu = ", fu;
puts;
startLog();
t = System.currentTimeMillis();
G ... | Ruby |
#
# jruby examples for jas.
# $Id$
#
require "examples/jas"
# U(sl_3) example
rs = """
# solvable polynomials, U(sl_3):
Rat(Xa,Xb,Xc,Ya,Yb,Yc,Ha,Hb) G
RelationTable
(
( Xb ), ( Xa ), ( Xa Xb - Xc ),
( Ya ), ( Xa ), ( Xa Ya - Ha ),
( Yc ), ( Xa ), ( Xa Yc + Yb ),
( Ha ), ( Xa ), ( Xa Ha + 2 Xa ),
( Hb ), ( Xa ),... | Ruby |
#
# jruby examples for jas.
# $Id$
#
require "examples/jas"
# Nabashima, ISSAC 2007, example Ex-4.8
# integral function coefficients
r = Ring.new( "IntFunc(a, b, c) (y,x) L" );
puts "Ring: " + str(r);
puts;
ps = """
(
( { a } x^2 + { b } y^2 ),
( { c } x^2 + y^2 ),
( { 2 a } x - { 2 c } y )
)
""";
#startLog();... | Ruby |
#
# jruby examples for jas.
# $Id$
#
require "examples/jas"
# mark, d-gb diplom example
r = Ring.new( "Z(x,y,z) L" );
puts "Ring: " + str(r);
puts;
ps = """
(
( z + x y**2 + 4 x**2 + 1 ),
( y**2 z + 2 x + 1 ),
( x**2 z + y**2 + x )
)
""";
f = r.ideal( ps );
puts "Ideal: " + str(f);
puts;
#startLog();
eg = f... | Ruby |
#
# jruby examples for jas.
# $Id$
#
require "examples/jas"
# Montes JSC 2002, 33, 183-208, example 11.4
# integral function coefficients
R = PolyRing.new( PolyRing.new(QQ(),"Q2, P2, Q1, P1",PolyRing.lex), "f3, e3, f2, e2", PolyRing.lex );
puts "Ring: " + str(R);
puts;
one, Q2, P2, Q1, P1, f3, e3, f2, e2 = R.gens()... | Ruby |
#
# jruby examples for jas.
# $Id: $
#
require "examples/jas"
#startLog();
# example form Moeller, Mora, Traverso
#r = PolyRing.new(QQ(),"t,z,y,x",PolyRing.grad);
r = PolyRing.new(QQ(),"z,y,x",PolyRing.grad);
#r = PolyRing.new(QQ(),"x,y,z",PolyRing.grad);
print "Ring: " + str(r);
print;
#one,t,z,y,x = r.gens();
on... | Ruby |
#
# jruby examples for jas.
# $Id$
#
require "examples/jas"
# simple example for comprehensive GB
# integral/rational function coefficients
#r = Ring( "RatFunc(u,v) (x,y) L" );
#r = Ring.new( "IntFunc(u,v) (x,y) L" );
r = PolyRing.new( PolyRing.new(ZZ(),"(u,v)",PolyRing.lex),"(x,y)", PolyRing.lex );
puts "Ring: " + ... | Ruby |
#
# jruby examples for jas.
# $Id$
#
require "examples/jas"
# Nabashima, ISSAC 2007, example F5
# integral function coefficients
r = Ring.new( "IntFunc(b, a, c) (x,y) L" );
puts "Ring: " + str(r);
puts;
ps = """
(
( { a } x^2 y + { b } x + y^2 ),
( { a } x^2 y + { b } x y ),
( y^2 + { b } x^2 y + { c } x y )
)
... | Ruby |
#
# jruby examples for jas.
# $Id$
#
require "examples/jas"
# polynomial examples: squarefree: characteristic p, infinite
r = PolyRing.new( RF(PolyRing.new(ZM(5,field=true),"u, v",PolyRing.lex)), "x y z",PolyRing.lex);
puts "r = " + str(r);
one,u,v,x,y,z = r.gens();
puts "one = " + str(one);
puts "u = " + str(... | Ruby |
#
# jruby examples for jas.
# $Id$
#
require "examples/jas"
# rational function coefficients
# IP (alpha,beta,gamma,epsilon,theta,eta)
# (c3,c2,c1) /G/
#r = Ring( "IntFunc(alpha,beta,gamma,epsilon,theta,eta)(c3,c2,c1) G" );
# ( { alpha } c1 - { beta } c1**2 - { gamma } c1 c2 + { epsilon } c3 ),
# ( - { gamma } c1 c2 ... | Ruby |
#
# jruby examples for jas.
# $Id$
#
require "examples/jas"
# characteristic set example Circle of Apollonius, from CLO IVA
#r = PolyRing.new( QQ(),"u1,u2,u3,u4,x1,x2,x3,x4,x5,x6,x7,x8",PolyRing.lex );
r = PolyRing.new( QQ(),"u1,u2,x1,x2,x3,x4,x5,x6,x7,x8",PolyRing.lex );
puts "Ring: " + str(r);
puts;
#one,u1,u2,u3... | Ruby |
#
# jruby examples for jas.
# $Id$
#
require "examples/jas"
# system biology examples: GB in Z_2
# see: Informatik Spektrum, 2009, February,
# Laubenbacher, Sturmfels: Computer Algebra in der Systembiologie
r = PolyRing.new(ZM(2),"M, B, A, L, P",PolyRing.lex);
puts "PolyRing: " + str(r);
puts;
one,M,B,A,L,P = r.gen... | Ruby |
#
# jruby examples for jas.
# $Id$
#
require "examples/jas"
# multiple algebraic field extensions
startLog();
puts "------- multiple algebraic field extensions QQ(alpha)(beta)(gamma)(delta) ---------";
r = PolyRing.new(QQ(),"alpha",PolyRing.lex);
puts "r = " + str(r);
e,a = r.gens();
puts "e = " + str(e);
p... | Ruby |
#
# jruby examples for jas.
# $Id$
#
require "examples/jas"
# Nabashima, ISSAC 2007, example F2
# integral function coefficients
r = Ring.new( "IntFunc(b, a) (x,y) L" );
puts "Ring: " + str(r);
puts;
ps = """
(
( { a } x^2 y^3 + { b } y + y ),
( x^2 y^2 + x y + 2 ),
( { a } x^2 + { b } y + 2 )
)
""";
#startLog... | Ruby |
#
# jruby examples for jas.
# $Id$
#
require "examples/jas"
# hermite polynomial example
# H(0) = 1
# H(1) = 2 * x
# H(n) = 2 * x * H(n-1) - 2 * (n-1) * H(n-2)
r = Ring.new( "Z(x) L" );
puts "Ring: " + str(r);
puts;
# sage like: with generators for the polynomial ring
one,x = r.gens();
x2 = 2 * x;
N = 10;
H = [on... | Ruby |
#
# jruby examples for jas.
# $Id$
#
require "examples/jas"
# examples for power series
#
# rational number examples
#
psr = SeriesRing.new("Q(y)");
puts "psr: " + str(psr);
puts;
one = psr.one();
puts "one: " + str(one);
#puts;
zero = psr.zero();
puts "zero: " + str(zero);
puts;
r1 = psr.random(4);
puts "r1: " ... | Ruby |
#
# jruby examples for jas.
# $Id$
#
require "examples/jas"
# Montes JSC 2002, 33, 183-208, example 5.1, simplified
# integral function coefficients
r = PolyRing.new( PolyRing.new(QQ(),"a, b",PolyRing.lex), "u,z,y,x", PolyRing.lex );
puts "Ring: " + str(r);
puts;
one,a,b,u,z,y,x = r.gens();
puts "gens: " + r.gens()... | Ruby |
#
# jruby examples for jas.
# $Id$
#
require "examples/jas"
# Nabashima, ISSAC 2007, example F1
# integral function coefficients
r = Ring.new( "IntFunc(a, b) (y,x) G" );
puts "Ring: " + str(r);
puts;
ps = """
(
( { a } x^4 y + x y^2 + { b } x ),
( x^3 + 2 x y ),
( { b } x^2 + x^2 y )
)
""";
#startLog();
f = r... | Ruby |
#
# jruby examples for jas.
# $Id$
#
require "examples/jas"
# examples for power series
#
# rational number examples
#
psr = MultiSeriesRing.new("Q(x,y,z)",truncate=4);
puts "psr: " + str(psr);
puts;
one = psr.one();
puts "one: " + str(one);
#puts;
zero = psr.zero();
puts "zero: " + str(zero);
puts;
r1 = psr.ran... | Ruby |
#
# jruby examples for jas.
# $Id$
#
require "examples/jas"
# Nabashima, ISSAC 2007, example F8
# modified, take care
# integral function coefficients
#r = Ring.new( "IntFunc(d, b, a, c) (y,x,w,z) L" );
r = Ring.new( "IntFunc(d, b, a, c) (y,x,w,z) G" );
#r = Ring.new( "IntFunc(d, b, c, a) (w,z,y,x) G" );
#r = Ring.... | Ruby |
#
# jruby examples for jas.
# $Id$
#
#load "examples/jas.rb"
require "examples/jas"
# non-commutative polynomial examples: evans example
r = WordPolyRing.new(QQ(),"x,y,z");
puts "WordPolyRing: " + str(r);
puts;
one,x,y,z = r.gens();
puts "one = " + str(one);
puts "x = " + str(x);
puts "y = " + str(y);
puts "z = " +... | Ruby |
#
# jruby examples for jas.
# $Id$
#
require "examples/jas"
# polynomial examples: ideal prime decomposition in char p > 0, inseparable cases
cr = PolyRing.new(ZM(5),"c",PolyRing.lex);
puts "coefficient Ring: " + str(cr);
rf = RF(cr);
puts "coefficient quotient Ring: " + str(rf.ring);
r = PolyRing.new(rf,"x,y,z",Po... | Ruby |
#
# jruby examples for jas.
# $Id$
#
require "examples/jas"
# Armbruster module example
r = CommutativeModule.new( "Rat(u,v,l) L" );
puts "Module: " + str(r);
puts;
ps = """
(
( ( 1 ), ( 2 ), ( 0 ), ( l^2 ) ),
( ( 0 ), ( l + 3 v ), ( 0 ), ( u ) ),
( ( 1 ), (... | Ruby |
#
# jruby examples for jas.
# $Id$
#
require "examples/jas"
# Montes JSC 2002, 33, 183-208, example 11.1
# integral function coefficients
r = PolyRing.new( PolyRing.new(QQ(),"c, b, a",PolyRing.lex), "z,y,x", PolyRing.lex );
puts "Ring: " + str(r);
puts;
one,c,b,a,z,y,x = r.gens();
puts "gens: " + r.gens().each{ |f|... | Ruby |
#
# jruby examples for jas.
# $Id$
#
require "examples/jas"
# polynomial examples: ideal radical decomposition, inseparable cases, dim > 0
#noThreads(); # must be called very early
cr = PolyRing.new(ZM(5),"c",PolyRing.lex);
puts "coefficient Ring: " + str(cr);
rf = RF(cr);
puts "coefficient quotient Ring: " + str(r... | 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 |
#!/usr/bin/env ruby
# jsonschema2objc.rb
# Author: Francois Proulx
# Author: Philippe Bernery
# Copyright 2010 Backelite. All rights reserved.
#
# jsonschema2objc is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation... | Ruby |
# Require any additional compass plugins here.
project_type = :stand_alone
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "css"
sass_dir = "scss"
images_dir = "images"
javascripts_dir = "javascript"
output_style = :compact
line_comments = false
# To enable relative paths to assets via ... | Ruby |
# Require any additional compass plugins here.
require 'compass-colors'
project_type = :stand_alone
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "css"
sass_dir = "scss"
images_dir = "images"
javascripts_dir = "javascript"
output_style = :compact
line_comments = false
# To enable rela... | Ruby |
# Require any additional compass plugins here.
require 'compass-colors'
project_type = :stand_alone
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "css"
sass_dir = "scss"
images_dir = "images"
javascripts_dir = "javascript"
output_style = :compact
# To enable relative paths to assets ... | Ruby |
get '/lib/*' do |path|
send_file File.dirname(__FILE__) + '/../lib/' + path
end | Ruby |
# Require any additional compass plugins here.
require 'compass-colors'
project_type = :stand_alone
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "css"
sass_dir = "scss"
images_dir = "images"
javascripts_dir = "javascript"
output_style = :compact
# To enable relative paths to assets ... | Ruby |
# Require any additional compass plugins here.
require 'compass-colors'
project_type = :stand_alone
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "css"
sass_dir = "scss"
images_dir = "images"
javascripts_dir = "javascript"
output_style = :compact
# To enable relative paths to assets v... | 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 |
class RubyLibraryExample
def get_server_language
'ruby'
end
# Basic communication
def passing
end
def failing(message)
raise message
end
def logging(message, level='INFO')
puts "*#{level}* #{message}"
end
def returning
'returned string'
end
# Logging
def one_message_w... | Ruby |
#!/usr/bin/env ruby
require 'rubygems'
require 'mqtt'
MQTT::Client.connect('localhost',1883) do |client|
client.get('#') do |topic,message|
puts "#{topic}: #{message}"
end
end
| Ruby |
source :gemcutter
gem 'sinatra', :require => 'sinatra/base'
gem 'thin', '~> 1.3'
gem 'pg'
gem 'data_mapper', '~> 1.2'
gem 'dm-postgres-adapter'
gem 'google-api-client', '>= 0.4.3'
group :development do
gem 'dm-sqlite-adapter', '~> 1.2'
gem 'do_sqlite3', '~> 0.10'
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 |
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.1'
# Use mysql as the database for Active Record
gem 'mysql2'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use Coff... | Ruby |
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run Rails.application
| 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__)
Rails.application.load_tasks
| 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 |
# Use this hook to configure devise mailer, warden hooks and so forth.
# Many of these configuration options can be set straight in your model.
Devise.setup do |config|
# ==> Mailer Configuration
# Configure the e-mail address which will be shown in Devise::Mailer,
# note that it will be overwritten if you use yo... | 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 the integrity of signed cookies.
# If you change this key, all old signed cookies 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 attac... | Ruby |
# Be sure to restart your server when you modify this file.
#
# This file contains settings for ActionController::ParamsWrapper which
# is enabled by default.
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters ... | Ruby |
# Be sure to restart your server when you modify this file.
BuffaloKids::Application.config.session_store :cookie_store, key: '_buffalo_kids_session'
# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
# (create the session table with... | 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 to debug a probl... | Ruby |
BuffaloKids::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# Code is not reloaded between requests
config.cache_classes = true
# Full error reports are disabled and caching is turned on
config.consider_all_requests_local = false
config.ac... | Ruby |
BuffaloKids::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 we... | Ruby |
BuffaloKids::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 tes... | Ruby |
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
BuffaloKids::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 defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
# Bundler.requi... | Ruby |
BuffaloKids::Application.routes.draw do
get "books/index" => "books#index"
post "book_reservations/new/:book_id" => "book_reservations#new"
post "book_reservations/delete/:book_reservation_id" => "book_reservations#delete"
get "book_reservations/index/:page" => "book_reservations#index"
get "book_reserva... | Ruby |
module ApplicationHelper
end
| Ruby |
module UserHelper
end
| Ruby |
class BookInstance < ActiveRecord::Base
attr_accessible :book_instance_code, :user_id, :book_id, :photo_registration_id, :book_reservation_id
belongs_to :book
belongs_to :book_reservation
belongs_to :photo_registration
validates_presence_of :book_instance_code;
validates_uniqueness_of :book_instance_code;
... | Ruby |
class PhotoRegistration < ActiveRecord::Base
attr_accessible :user_id, :finish_date, :quantity
belongs_to :user
has_one :book_instance
has_one :book, :through => :book_instance
self.per_page = 12
end
| Ruby |
class Book < ActiveRecord::Base
attr_accessible :title,
:book_code,
:description,
:author,
:image_url,
:release_date,
:rating
validates_uniqueness_of :title, :book_code
validates_presence_of :title, :book_code
before_validation :default_image_url
... | Ruby |
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable, :confirmable
# Setup acc... | Ruby |
class BookReservation < ActiveRecord::Base
attr_accessible :user_id, :start_date, :due_date, :extention_days
belongs_to :user
has_one :book_instance
has_one :book, :through => :book_instance
self.per_page = 12
end
| Ruby |
class Notice < ActiveRecord::Base
attr_accessible :title,
:content,
:user_id
validates :title, :content, :presence => true
belongs_to :user
self.per_page = 12
def short_content
self.content.truncate(30)
end
end
| Ruby |
class BookReservationsController < ApplicationController
before_filter :authenticate_user!
def home
@books = Book.paginate(:page => params[:page])
end
def new
book = Book.find_by_id(params[:book_id])
if current_user.book_reservations.map{ |a| a.book }.include? book
#send some error message
... | Ruby |
class BookManagementsController < ApplicationController
before_filter :authenticate_user!
def index
@vbooks = Book.paginate(:page => params[:page])
end
def show
@sbook = Book.find_by_id(params[:book_id])
end
def edit
@ebook = Book.find_by_id(params[:book_id])
end
def new
... | Ruby |
class PhotoRegistrationsController < ApplicationController
before_filter :authenticate_user!
def home
@books = Book.paginate(:page => params[:page])
end
def new
book = Book.find_by_id(params[:book_id])
if current_user.photo_registrations.map{ |a| a.book }.include? book
#send some error message... | Ruby |
class BooksController < ApplicationController
# phan cua Viet
before_filter :authenticate_user!
def index
@books = Book.paginate(:page => params[:page])
end
def show
@book = Book.find_by_id(params[:book_id])
end
def edit
@book = Book.find_by_id(params[:book_id])
end
def upd... | Ruby |
class ApplicationController < ActionController::Base
protect_from_forgery
def after_sign_in_path_for(resource_or_scope)
case resource_or_scope.role
when "admin"
"/users/index/1"
when "user"
"/book_reservations/home/1"
when "librarian"
"/books/index/1"
end
end
end
| Ruby |
class BookInstancesController < ApplicationController
def index
@book = Book.find(params[:book_id])
if @book.nil?
# send error message
else
@book_instances = @book.book_instances.paginate(:page => params[:page])
if @book_instances.empty?
# error message
redirect_to "/books/show/#{param... | Ruby |
class NoticesController < ApplicationController
before_filter :authenticate_user!
def index
@notices = Notice.paginate(:page => params[:page])
end
def show
@notice = Notice.find_by_id params[:notice_id]
end
def edit
@notice_edit = Notice.find_by_id(params[:notice_id])
end
def new
end... | Ruby |
class UsersController < ApplicationController
before_filter :authenticate_user!
def welcome
end
def index
@users = User.paginate(:page => params[:page])
end
def show
@user = User.find_by_id(params[:user_id])
end
def new
@user = User.new
end
def edit
@user = User.find_by_id(params[:user_id])
end
... | Ruby |
#!/usr/bin/env rake
# 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__)
BuffaloKids::Application.load_tasks
| Ruby |
#!/usr/bin/env rake
# 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__)
BuffaloKids::Application.load_tasks
| Ruby |
source 'https://rubygems.org'
gem 'rails', '3.2.8'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
group :development, :test do
gem 'mysql2'
end
group :production do
gem 'pg'
end
gem "mysql2"
gem 'haml', '3.1.7'
gem 'devise', '2.1.2'
gem 'jquery-rails', '2.1.2'
gem 'will_... | Ruby |
class DeviseCreateUsers < ActiveRecord::Migration
def change
create_table(:users) do |t|
## Database authenticatable
t.string :email, :null => false, :default => ""
t.string :encrypted_password, :null => false, :default => ""
## Recoverable
t.string :reset_password_to... | Ruby |
class CreateBooks < ActiveRecord::Migration
def change
create_table :books do |t|
t.string :title
t.string :book_code
t.string :description
t.string :author
t.string :category
t.date :release_date
t.string :image_url
t.string :rating
t.boolean :available
... | Ruby |
class CreateNotices < ActiveRecord::Migration
def change
create_table :notices do |t|
t.string :title
t.string :content
t.integer :user_id
t.timestamps
end
end
end
| Ruby |
class CreatePhotoRegistrations < ActiveRecord::Migration
def change
create_table :photo_registrations do |t|
t.integer :user_id
t.date :finish_date
t.string :quantity
t.timestamps
end
end
end
| Ruby |
class CreateBookReservations < ActiveRecord::Migration
def change
create_table :book_reservations do |t|
t.integer :user_id
t.date :start_date
t.date :due_date
t.integer :extention_days
t.timestamps
end
end
end
| Ruby |
class CreateBookInstances < ActiveRecord::Migration
def change
create_table :book_instances do |t|
t.string :book_instance_code
t.integer :user_id
t.integer :book_id
t.integer :book_reservation_id
t.integer :photo_registration_id
t.timestamps
end
end
end
| Ruby |
User.delete_all
Notice.delete_all
Book.delete_all
BookInstance.delete_all
BookReservation.delete_all
PhotoRegistration.delete_all
user1 = User.create(:email => "user1@vit.com", :password => "123456", :username => "user1", :confirmed_at => Time.now)
user2 = User.create(:email => "user2@vit.com", :password => "123456", ... | Ruby |
FactoryGirl.define do
factory :book do
sequence(:title) {|n| "book#{n}" }
sequence(:book_code) {|n| "book_code#{n}" }
end
end | Ruby |
FactoryGirl.define do
factory :book_instance do
sequence(:book_instance_code) {|n| "book_instance_code#{n}" }
end
end | Ruby |
FactoryGirl.define do
factory :user do
sequence(:email) {|n| "email#{n}@example.com" }
sequence(:username) {|n| "username#{n}" }
password "123456"
password_confirmation "123456"
end
factory :unconfirmed_user, :parent => :user do
confirmation_token "confirmation_token"
end
fac... | Ruby |
FactoryGirl.define do
factory :book_reservation do
start_date Date.today
due_date Date.today + 3
end
end | Ruby |
FactoryGirl.define do
factory :photo_registration do
finish_date Date.today + 3
end
end | Ruby |
FactoryGirl.define do
factory :notice do
title "Notice Title"
content "Notice Content"
end
end | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.