code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
#!/usr/bin/ruby
# -*- ruby -*-
#
# http://www.reddit.com/r/dailyprogrammer/comments/z6o4k/9012012_challenge_94_easy_elemental_symbols_in/
require 'set'
_elements = %w{
H He Li Be B C N O F Ne Na Mg Al Si P S
Cl Ar K Ca Sc Ti V Cr Mn Fe Co Ni Cu Zn Ga Ge
As Se Br Kr Rb S... | Ruby |
#!/usr/bin/ruby
# -*- ruby -*-
#
# http://www.reddit.com/r/dailyprogrammer/comments/164zvs/010713_challenge_116_easy_permutation_of_a_string/
require 'set'
def perm(s, curr = "", acc = Set.new)
s = s.split("") if s.is_a?(String)
unless s.empty?
(0 .. s.size - 1).each do |i|
c = s[i]
... | Ruby |
#!/usr/bin/ruby
# -*- ruby -*-
#
# http://www.reddit.com/r/dailyprogrammer/comments/1q6pq5/11413_challenge_140_easy_variable_notation/
class Processor
def separator
end
def transform_token(word)
return word
end
def post_process(joined)
return joined
end
def input(str)
raise "Implement me"
... | Ruby |
#!/usr/bin/ruby
# -*- ruby -*-
#
# http://www.reddit.com/r/dailyprogrammer/comments/1ee664/050813_challenge_124_intermediate_circular_graphs/
require 'pp'
require 'set'
g = {}
cycles = []
STDIN.readlines.each do |line|
src, dst = line.strip.split(' ')
next if dst.nil?
# Get paths that terminate at the src
... | Ruby |
#!/usr/bin/ruby
# -*- ruby -*-
#
# http://www.reddit.com/r/dailyprogrammer/comments/101m7y/9172012_challenge_99_easy_words_with_letters_in/
dictionary = ARGV.first || File.basename($0).gsub(/\.rb$/, '.input')
approach = :sorting
File.open(dictionary) do |dictionary_fh|
dictionary_fh.readlines.each do |line|
li... | Ruby |
require 'compass'
Compass::Frameworks.register("sassy-math", :path => "#{File.dirname(__FILE__)}/..")
# Sassy math Functions
module Sass::Script::Functions
# Exponents
def exponent(base, powerNum, powerDen)
base = base.value.to_f
powerNum = powerNum.value.to_f
powerDen = powerDen.value.to_f
result ... | Ruby |
require 'compass'
Compass::Frameworks.register('sassy-math', :path => File.expand_path("../.."))
# This tells Compass what your Compass extension is called, and where to find
# its files
# Replace 'extension' with the name of your extension. Spaces allowed.
extension_path = File.expand_path(File.join(File.dirname(__... | Ruby |
# Require any additional compass plugins here.
# Tell compass where to find local extensions
# If you followed directions and ran 'gem install modular-scale' comment the next two lines out:
extensions_dir = "sass/extensions"
Compass::Frameworks.register('modular-scale', :path => File.expand_path("#{extensions_dir}/mo... | 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: 'Emanuel... | Ruby |
class CreateLogs < ActiveRecord::Migration
def change
create_table :logs do |t|
t.string :login, :null => false
t.string :mensagem, :null => false
t.timestamps
end
end
end
| Ruby |
class CreateUsuariosPacientes < ActiveRecord::Migration
def change
create_table :usuarios_pacientes do |t|
t.string :login, :null => false
t.string :senha, :null => false
t.string :nome, :null => false
t.string :sobrenome, :null => false
t.string :ema... | Ruby |
class CreateDadosExames < ActiveRecord::Migration
def change
create_table :dados_exames do |t|
t.datetime :inicio, :null => false
t.text :comentarios
t.boolean :notificar, :default => true
t.references :paciente, :null => false
t.timestamps
end
end
end
| Ruby |
class CreateUsuariosPermissaos < ActiveRecord::Migration
def change
create_table :usuarios_permissaos do |t|
t.references :paciente, :null => false
t.references :medico, :null => false
t.boolean :notificar, :default => true
t.timestamps
end
end
end
| Ruby |
class CreateUsuariosMedicos < ActiveRecord::Migration
def change
create_table :usuarios_medicos do |t|
t.string :login, :null => false
t.string :senha, :null => false
t.string :nome, :null => false
t.string :sobrenome, :null => false
t.string :email, ... | Ruby |
class CreateUsuariosAdministradors < ActiveRecord::Migration
def change
create_table :usuarios_administradors do |t|
t.string :login, :null => false
t.string :senha, :null => false
t.string :nome, :null => false
t.string :sobrenome, :null => false
t.s... | Ruby |
class CreateDadosAcelerometros < ActiveRecord::Migration
def change
create_table :dados_acelerometros do |t|
t.integer :eixo_x, :default => 0
t.integer :eixo_y, :default => 0
t.integer :eixo_z, :default => 0
t.integer :intervalo, :null => false
t.references :exame, :null => false
... | Ruby |
class CreateDadosEcgs < ActiveRecord::Migration
def change
create_table :dados_ecgs do |t|
t.integer :derivacao_1, :default => 0
t.integer :derivacao_2, :default => 0
t.integer :derivacao_3, :default => 0
t.integer :intervalo, :null => false
t.references :exame, :null => false
... | Ruby |
# encoding: UTF-8
require 'digest/sha1'
require "time"
require "net/http"
require "net/https"
require "uri"
require "json"
@uri_auth = URI.parse("https://192.168.198.128/service/verificar_autenticacao")
@uri = URI.parse("https://192.168.198.128/service/atualizar_exame")
@usuario = "paciente"
@senha = "123456"
inicio... | 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 |
#!/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__)
MonitServer::Application.load_tasks
| Ruby |
source 'http://rubygems.org'
gem 'rails', '3.1.0'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql2'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', " ~> 3.1.0"
gem 'coffee-rails', "~> ... | Ruby |
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
require 'rails/commands'
| Ruby |
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
require 'rails/commands'
| Ruby |
module ApplicationHelper
end
| Ruby |
module Usuarios::MedicoHelper
end
| Ruby |
module Usuarios::PacienteHelper
end
| Ruby |
module Usuarios::AdministradorHelper
end
| Ruby |
module Usuarios::PermissaoHelper
end
| Ruby |
module LogHelper
end
| Ruby |
module LoginHelper
end
| Ruby |
module ServiceHelper
end
| Ruby |
module Dados::ExameHelper
end
| Ruby |
class UsuarioMailer < ActionMailer::Base
default from: "sistema.sobpressao@gmail.com"
def nova_senha(user, senha)
@login = user.login
@senha = senha
mail(:to => user.email, :subject => "Nova senha para acesso ao Heart Net.")
end
def novo_cadastro(user, senha)
@tipo = user.class.name.partitio... | Ruby |
# encoding: UTF-8
class Usuarios::Administrador < ActiveRecord::Base
attr_accessor :confirmacao_senha
validates :nome, :presence => true
validates :login, :presence => true
#, :uniqueness => true
validates :senha, :presence => true,
... | Ruby |
# encoding: UTF-8
class Usuarios::Medico < ActiveRecord::Base
attr_accessor :confirmacao_senha
has_many :permissoes, :class_name => "Usuarios::Permissao"
has_many :pacientes, :class_name => "Usuarios::Paciente", :through => :permissoes
validates :nome, :presence => true
validat... | Ruby |
# encoding: UTF-8
class Usuarios::Paciente < ActiveRecord::Base
SEXO = {1 => "Masculino", 2 => "Feminino"}
attr_accessor :confirmacao_senha
has_many :exames, :class_name => "Dados::Exame"
has_many :permissoes, :class_name => "Usuarios::Permissao"
has_many :medicos, :class_name =... | Ruby |
class Usuarios::Permissao < ActiveRecord::Base
belongs_to :paciente, :class_name => "Usuarios::Paciente"
belongs_to :medico, :class_name => "Usuarios::Medico"
def criar
self.save
end
def atualizar(parametros)
self.notificar = parametros[:notificar]
self.save
end
def remover
sel... | Ruby |
module Dados
def self.table_name_prefix
'dados_'
end
end
| Ruby |
class Log < ActiveRecord::Base
end
| Ruby |
module Usuarios
def self.table_name_prefix
'usuarios_'
end
end
| Ruby |
# encoding: UTF-8
class Dados::Ecg < ActiveRecord::Base
belongs_to :exame, :class_name => "Dados::Exame"
def self.criar_dados(exame, dados)
dados.each do |indice, conteudo|
if conteudo[:derivacao_1] and conteudo[:derivacao_2]
conteudo[:derivacao_3] = conteudo[:derivacao_1].to_i - conteudo[:deri... | Ruby |
# encoding: UTF-8
class Dados::Acelerometro < ActiveRecord::Base
belongs_to :exames, :class_name => "Dados::Exame"
def self.criar_dados(exame, dados)
dados.each do |indice, conteudo|
acel = Dados::Acelerometro.new(conteudo)
acel.exame_id = exame.id
if not acel.save
return false
... | Ruby |
# encoding: UTF-8
class Dados::Exame < ActiveRecord::Base
belongs_to :paciente, :class_name => "Usuarios::Paciente"
has_many :ecgs, :class_name => "Dados::Ecg"
has_many :acelerometros, :class_name => "Dados::Acelerometro"
def self.notificar
Dados::Exame.where(:notificar => true).each... | Ruby |
# encoding: UTF-8
class Usuarios::MedicoController < ApplicationController
before_filter :verifica_administrador, :only => [:novo, :criar, :remover]
before_filter :verifica_administrador_medico, :only => [:editar, :atualizar]
before_filter :verifica_administrador_paciente_medico, :only => [:visualizar]
before... | Ruby |
# encoding: UTF-8
class Usuarios::PacienteController < ApplicationController
before_filter :verifica_administrador, :only => [:novo, :criar, :remover]
before_filter :verifica_administrador_medico, :only => [:listar]
before_filter :verifica_administrador_paciente, :only => [:editar, :atualizar]
before_filter :... | Ruby |
class Usuarios::PermissaoController < ApplicationController
before_filter :verifica_paciente, :only => [:adicionar_permissao, :remover_permissao]
before_filter :verifica_medico, :only => [:ativar_notificacao, :desativar_notificacao]
def adicionar_permissao
@medico = Usuarios::Medico.buscar_ativos(:id => par... | Ruby |
# encoding: UTF-8
class Usuarios::AdministradorController < ApplicationController
layout "application"
before_filter :verifica_administrador
# O administrador pode criar outros administradores
# mas apenas o especial pode remover e editar outros administradores
def novo
@administrador = Usuarios::Adm... | Ruby |
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :set_language
# Não é o melhor lugar para se definir isso
I18n.default_locale = :"pt-br"
def set_language
available = %w{en pt-br}
default_lang = request.compatible_language_from(available)
I18n.loca... | Ruby |
class LogController < ApplicationController
before_filter :verifica_administrador
def listar
if params[:filtro]
@logs = Log.where("login LIKE ?", '%' + params[:filtro][:login] + '%')
.paginate(:page => params[:page], :per_page => 10).order('created_at DESC')
@filtro_params = {:log... | Ruby |
# encoding: UTF-8
class LoginController < ApplicationController
layout "application"
def index
session[:administrador_id] = nil
session[:medico_id] = nil
session[:paciente_id] = nil
end
def autenticar
if params[:usuario][:login].present?
login = params[:usuario][:login]
# Verif... | Ruby |
# encoding: UTF-8
class Dados::ExameController < ApplicationController
before_filter :verifica_medico
def listar
@paciente = Usuarios::Paciente.buscar_ativos(:id => params[:id]).first
if @paciente
@exames = {}
@paciente.exames.order("inicio DESC").each do |item|
@exames[item.inicio.st... | Ruby |
# encoding: UTF-8
class ServiceController < ActionController::Base
before_filter :autenticar
def atualizar_exame
if request.post?
# Cria o exame caso ele não exista
if params[:inicio].nil?
render :text => "Dados invalidos de exame", :status => 400
else
@exame = Dados::Exame.... | 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.
# 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 |
# 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.
# 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.
# 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.
MonitServer::Application.config.session_store :cookie_store, key: '_MonitServer_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 |
MonitServer::Application.routes.draw do
# 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
# Sample of named route:
# match 'p... | 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 |
# Use this file to easily define all of your cron jobs.
#
# It's helpful, but not entirely necessary to understand cron before proceeding.
# http://en.wikipedia.org/wiki/Cron
# Example:
#
# set :output, "/path/to/my/cron_log.log"
#
# every 2.hours do
# command "/usr/bin/some_great_command"
# runner "MyModel.some_m... | 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.requir... | Ruby |
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
MonitServer::Application.initialize!
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "SobPressao.com.br",... | Ruby |
MonitServer::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 |
MonitServer::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 w... | Ruby |
MonitServer::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 t... | Ruby |
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run MonitServer::Application
| 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__)
MonitServer::Application.load_tasks
| Ruby |
namespace :db do
desc "Populates Database"
task :populate => :environment do
puts "Criando paciente:123456"
Usuarios::Paciente.create(:nome => "Paciente", :sobrenome => "Pessoa", :login => "paciente",
:senha => "123456", :confirmacao_senha => "123456", :email => "paciente@pesso... | 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 |
environment = :production
project_type = :stand_alone
http_path = "/"
css_dir = "../styles"
sass_dir = "."
images_dir = "images"
sass_options = {
:line_numbers => false,
:debug_info => false
}
# output_style = :compressed
# output_style = :compact
output_style = :expanded
| Ruby |
require 'webrick'
include WEBrick
s = HTTPServer.new(
:Port => 2010,
:DocumentRoot => Dir::pwd
)
s.mount('/sh/scripts', WEBrick::HTTPServlet::FileHandler, '../scripts')
s.mount('/sh/styles', WEBrick::HTTPServlet::FileHandler, '../styles')
trap('INT') { s.stop }
s.start
| Ruby |
source 'https://rubygems.org'
gem 'rake'
gem 'therubyracer'
gem 'uglifier' | Ruby |
require 'rubygems'
require 'bundler'
require 'fileutils'
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts "Run `bundle install` to install missing gems"
exit e.status_code
end
ROOT = File.dirname(__FILE__)
require 'rake'
require 'uglifier'
task... | Ruby |
source 'https://rubygems.org'
gem 'jekyll', '~> 1.0'
gem 'debugger'
| Ruby |
##
# Provide an icons attribute on the site object
require 'yaml'
require 'forwardable'
module Jekyll
class Icon
attr_reader :name, :id, :unicode, :created, :categories
def initialize(icon_object)
@icon_object = icon_object
# Class name used in CSS and HTML
@icon_object['class'] = icon... | Ruby |
##
# Create individual pages for each icon in the FontAwesome set
require 'yaml'
require 'debugger'
module Jekyll
class IconPage < Page
##
# Take a single icon and render a page for it.
def initialize(site, base, dir, icon)
@site = site
@base = base
@dir = dir
@name = "#{icon.... | Ruby |
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{fitnesse}
s.version = "0.0.1"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = [" full name"]
s.date = %q{2010-02-07}
s.description = %q{FIX (describe your package)}
s.e... | Ruby |
require 'rubygems'
gem 'hoe', '>= 2.1.0'
require 'hoe'
require 'fileutils'
require './lib/fitnesse'
Hoe.plugin :newgem
# Hoe.plugin :website
# Hoe.plugin :cucumberfeatures
# Generate all the Rake tasks
# Run 'rake -T' to see list of generated tasks (from gem root directory)
$hoe = Hoe.spec 'fitnesse' do
self.develo... | Ruby |
dir = File.dirname(__FILE__)
Dir[File.expand_path("#{dir}/**/*.rb")].uniq.each do |file|
require file
end | Ruby |
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'spec/rails/story_adapter' | Ruby |
class CreateForums < ActiveRecord::Migration
# Declare the Forum model here so that the code below works even if you
# change app/models/forum.rb by (say) adding validations.
class Forum < ActiveRecord::Base
end
def self.up
create_table :forums do |t|
t.string :name
t.text :description
... | Ruby |
class AddEmailUniqueness < ActiveRecord::Migration
def self.up
remove_index :people, :email
add_index :people, :email, :unique => true
end
def self.down
remove_index :people, :email
add_index :people, :email
end
end
| Ruby |
class CreateLocalKeys < ActiveRecord::Migration
include Crypto
def self.up
# Identifier for the tracker
File.open("identifier", "w") do |f|
f.write UUID.new
end unless File.exist?("identifier")
# RSA keys for user authentication
Crypto.create_keys
end
def self.down
end
end
| Ruby |
class CreateTopics < ActiveRecord::Migration
def self.up
create_table :topics do |t|
t.integer :forum_id
t.integer :person_id
t.string :name
t.integer :forum_posts_count, :null => false, :default => 0
t.timestamps
end
add_index :topics, :forum_id
end
def self.down
... | Ruby |
class CreateBlogs < ActiveRecord::Migration
def self.up
create_table :blogs do |t|
t.integer :person_id
t.timestamps
end
end
def self.down
drop_table :blogs
end
end
| Ruby |
class AddAdmin < ActiveRecord::Migration
class Person < ActiveRecord::Base
end
class Blog < ActiveRecord::Base
end
def self.up
add_column :people, :admin, :boolean, :default => false, :null => false
add_column :people, :deactivated, :boolean,
:default => false, :null =>... | Ruby |
class AddEmailNotificationPreferences < ActiveRecord::Migration
def self.up
add_column :people, :connection_notifications, :boolean, :default => true
add_column :people, :message_notifications, :boolean, :default => true
add_column :people, :wall_comment_notifications, :boolean, :default => true
add_c... | Ruby |
class CreatePosts < ActiveRecord::Migration
def self.up
create_table :posts do |t|
t.integer :blog_id
t.integer :topic_id
t.integer :person_id
t.string :title
t.text :body
t.integer :blog_post_comments_count, :null => false, :default => 0
t.string :type
t.time... | Ruby |
class AddServerNameAndApp < ActiveRecord::Migration
def self.up
add_column :preferences, :server_name, :string
add_column :preferences, :app_name, :string
end
def self.down
remove_column :preferences, :app_name
remove_column :preferences, :server_name
end
end
| Ruby |
class AddOpenIdAuthenticationTables < ActiveRecord::Migration
def self.up
create_table :open_id_authentication_associations, :force => true do |t|
t.integer :issued, :lifetime
t.string :handle, :assoc_type
t.binary :server_url, :secret
end
create_table :open_id_authentication_nonces, :f... | Ruby |
class AddSomeIndices < ActiveRecord::Migration
def self.up
add_index :people, :admin
add_index :people, :deactivated
add_index :blogs, :person_id
add_index :activities, :person_id
end
def self.down
remove_index :activities, :person_id
remove_index :blogs, :person_id
remove_index :peop... | Ruby |
class AddPrivacyAndCacheAttendees < ActiveRecord::Migration
def self.up
add_column :events, :event_attendees_count, :integer, :default => 0
add_column :events, :privacy, :integer, :null => false
end
def self.down
remove_column :events, :event_attendees_count
remove_column :events, :privacy
end
... | Ruby |
class CreatePreferences < ActiveRecord::Migration
def self.up
# drop_table :preferences rescue nil
create_table :preferences do |t|
t.string :domain, :null => false, :default => ""
t.string :smtp_server, :null => false, :default => ""
t.boolean :email_notifications, :null => false, :default ... | Ruby |
class FixUpPageViews < ActiveRecord::Migration
def self.up
remove_column :page_views, :user_id
add_column :page_views, :person_id, :integer
add_index :page_views, [:person_id, :created_at]
end
def self.down
add_column :page_views, :user_id, :integer
remove_column :page_views, :perso... | Ruby |
class CreateComments < ActiveRecord::Migration
def self.up
create_table :comments do |t|
t.integer :commenter_id
t.integer :commentable_id
t.string :commentable_type, :default => "", :null => false
t.text :body
t.timestamps
end
add_index :comments, :commenter_id
add_... | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.