code
stringlengths
1
1.73M
language
stringclasses
1 value
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # # this exemple illustrates the use of the cparser/preprocessor #factorize functionnality: # it generates code that references to the functio...
Ruby
#!/usr/bin/env ruby # This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # # in this exemple we can write a shellcode using a C function # require 'metasm' # load and decode the file sc = Meta...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # # in this exemple we will patch a process specified on the commandline (pid or part of image name) # the IAT entry matching /WriteFile/ wil...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # this generates a signature file for all function in the given library # usage: gensigs.rb some_lib.a somefile.o somelib.lib > mylib.fsigs # ...
Ruby
#!/usr/bin/env ruby # This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # # compiles a PE file with the specified resource directory # TODO build an icon or something # require 'metasm' pe = ...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # this script show the assembler syntax understood by the framework require 'metasm' edata = Metasm::Shellcode.assemble(Metasm::Ia32.new, <<...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # this script compiles a source file (asm or C) into a shellcode that will # dynamically resolve the address of functions it uses # windows on...
Ruby
#!/usr/bin/env ruby # This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # # in this file, we open an existing PE, add some code to its last section and # patch the entrypoint so that we are exe...
Ruby
#!/usr/bin/env ruby # This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # # here we assemble a dummy MIPS PE # TODO autodetect header.machine from cpu, find something to put in # the MZ header, ...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # # this script takes a list of dll filenames as arguments, and outputs each lib export # libname, followed by the list of the exported symbol...
Ruby
#!/usr/bin/env ruby # This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # This sample implements a trivial binary diffing algorithm between two programs # the programs have first to be disassem...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # a preleminary attempt to use MS dbghelp.dll to retrieve PE symbols require 'metasm' dll = 'C:\\Program Files\\Debugging Tools For Windows ...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # # this exemple illustrates the use of the cparser/preprocessor #factorize functionnality: # we write some code using standard headers, and t...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory module ::Metasm module Gui class GraphHeapWidget < GraphViewWidget attr_accessor :heap, :addr_struct, :snapped # addr_struct = 0x234 => Allo...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory module Metasm class Heap attr_accessor :vm, :range, :ptsz attr_accessor :cp # hash chunk userdata pointer -> chunk userdata size attr_acc...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # metasm debugger plugin # adds a 'trace_func' method to the debugger # the methods sets a breakpoint at the beginning of a function, and log...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # metasm debugger plugin # adds some heap_* functions to interract with the target heap chunks # functions: # heap_scan, scan for malloc chu...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # # This script takes a C header or a path to a Visual Studio install and # outputs a ruby source file defining StackOffsets, a hash used by ...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # # this is a linux/x86 debugger with a console interface # require 'metasm' module Ansi CursHome = "\e[H".freeze ClearLineAfter = "\e[0K...
Ruby
#!/usr/bin/env ruby # This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # # this file takes preprocessor files as arguments # it preprocesses their content and dump the result to stdout # it als...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # # This sample defines an ApiHook class, that you can subclass to easily hook functions # in a debugged process. Your custom function will g...
Ruby
#!/usr/bin/env ruby # This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # # a sample application # require 'metasm' pe = Metasm::PE.assemble Metasm::Ia32.new, <<EOS .entrypoint push 0 push t...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # # in this exemple we will patch a process specified on the commandline (pid or part of the image name) # we will retrieve the user32.dll li...
Ruby
#!/usr/bin/env ruby # This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm' $opts = { :execlass => Metasm::PE, :srctype_data => 'c' } load File.join(File.dirname(__FILE__), 'exeenc...
Ruby
#!/usr/bin/env ruby # This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # # this sample shows the compilation of a slightly more complex program # it displays in a messagebox the result of CPUI...
Ruby
# # This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # this file sets up the RUBYLIB environment variable for windows hosts # the variable is set for the current user only # the user session ma...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # This samples generates a binary loader that will load and patch a Win32 program in memory # The patch data are read from assembly files name...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # # this is a simple executable tracer for Windows using the # Metasm windows debug api abstraction # all callbacks are full ruby, so this is...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # Original script and idea by Alexandre GAZET # # Licence is LGPL, see LICENCE in the top-level directory # # this script will load an upx-packed windows executable, find its # original entrypoint ...
Ruby
#!/usr/bin/env ruby # This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # modifies the standard ruby class String to add #decode and #encode methods # they will respectively disassemble binary d...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # shows the compilation phase step by step: c, simplified c, asm require 'metasm' require 'optparse' opts = { :cpu => 'Ia32', :exe => 'Shell...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm' Metasm.require 'samples/metasm-shell' include Metasm # open target WinOS.get_debug_privilege if not pr = WinOS.find_proces...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # # here we will build an executable file that will shut down the machine # when run # the header part comes from the factorize sample script...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # # here we build a simple a.out executable # require 'metasm' Metasm::AOut.assemble(Metasm::Ia32.new, <<EOS).encode_file('m-a.out') .text ....
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # # this script takes a list of dll filenames as arguments, and outputs each lib export # libname, followed by the list of the exported symbol...
Ruby
#!/usr/bin/env ruby # This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # # quick demonstration that the disassembler's backtracker works # require 'metasm' Metasm.require 'samples/metasm-shel...
Ruby
#!/usr/bin/env ruby # This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # # in this sample we compile 2 PE files, one executable and one dll # with the same base address, to check if the base r...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # # this exemple illustrates the use of the cparser/preprocessor #factorize functionnality: # it generates code that references to the functio...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # # this sample script fixes a bug in some GTK libs (eg debian) where at some point # when you close a window an invalid memory dereference i...
Ruby
#!/usr/bin/env ruby # This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm' $opts = { :execlass => Metasm::ELF, :exetype => :lib } load File.join(File.dirname(__FILE__), 'exeencode...
Ruby
#!/usr/bin/env ruby # This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # # this script reads a list of elf files, and lists its dependencies recursively # libraries are searched in LD_LIBRARY_...
Ruby
#!/usr/bin/env ruby # This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # # this script disassembles an executable (elf/pe) and dumps the output # ruby -h for help # require 'metasm' include M...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # # This exemple illustrates the usage of the C parser to compute the offset of members of a given structure # usage: struct_offset.rb <c file...
Ruby
#!/usr/bin/env ruby # This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # # this script disassembles an executable (elf/pe) using the GTK front-end # use live:bla to open a running process whos...
Ruby
#!/usr/bin/ruby # This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # # this exemple illustrates the use of the PTrace class to hijack a syscall in a running process # the next syscall made is ...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory Dir['tests/*.rb'].sort.each { |f| require f }
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'test/unit' require 'metasm' class TestDynldr < Test::Unit::TestCase def d; Metasm::DynLdr; end def test_new_api_c str = "1234" ...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'test/unit' require 'metasm/exe_format/shellcode' class TestEncodedData < Test::Unit::TestCase def compile(src) p = Metasm::Shell...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'test/unit' require 'metasm/preprocessor' require 'metasm/parse' # BEWARE OF TEH RUBY PARSER # use single-quoted source strings cla...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'test/unit' require 'metasm' class TestIa32 < Test::Unit::TestCase @@cpu32 = Metasm::Ia32.new @@cpu16 = Metasm::Ia32.new(16) def ...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'test/unit' require 'metasm' class TestDynldr < Test::Unit::TestCase def cp @cp ||= Metasm::Ia32.new.new_cparser end def test_p...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'test/unit' require 'metasm' class TestPreproc < Test::Unit::TestCase include Metasm def asm_dasm(src) @cpu ||= Ia32.new raw ...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'test/unit' require 'metasm' class TestArc < Test::Unit::TestCase def test_arc_dec hex_stream = "\x0A\x23\x80\x0F\x80\x...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'test/unit' require 'metasm' class TestExpression < Test::Unit::TestCase E = Metasm::Expression def test_encode assert_equal("\x...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'test/unit' require 'metasm' class TestX86_64 < Test::Unit::TestCase @@cpu = Metasm::X86_64.new def assemble(src, cpu=@@cpu) Met...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # special file to test the graph layout engine # call this file directly to run require 'metasm' include Metasm def test_layout(lo) $cur |...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'test/unit' require 'metasm' class TestMips < Test::Unit::TestCase def test_enc sc = Metasm::Shellcode.assemble(Metasm::MIPS.new(...
Ruby
# Require any additional compass plugins here. # Set this to the root of your project when deployed: http_path = "/" css_dir = "theme/css" sass_dir = "theme/scss" images_dir = "images" javascripts_dir = "js" # You can select your preferred output style here (can be overridden via the command line): output_style = :co...
Ruby
# Simple Jobs # =========== require 'java' java_import Java::MyscheduleQuartzExtraJob::LoggerJob java_import Java::MyscheduleQuartzExtraJob::ScriptingJob java_import Java::MyscheduleQuartzExtra::SchedulerTemplate java_import Java::JavaUtil::Date java_import Java::JavaLang::System # Schedule hourly job scheduler.schedu...
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 AddColumnStatusToMissao < ActiveRecord::Migration def self.up add_column :missaos, :status, :string end def self.down remove_column :missaos, :status end end
Ruby
class CreatePergunta < ActiveRecord::Migration def self.up create_table :pergunta do |t| t.integer :nivel_id t.text :caput t.text :flag_primeira t.integer :pergunta_id t.timestamps end end def self.down drop_table :pergunta end end
Ruby
class CreateJogadorsMissaosJoinTable < ActiveRecord::Migration def self.up create_table :jogadors_missaos, :id => false do |t| t.integer :jogador_id t.integer :missao_id end end def self.down drop_table :jogadors_missaos end end
Ruby
class CreateMissaos < ActiveRecord::Migration def self.up create_table :missaos do |t| t.string :descricao t.timestamps end end def self.down drop_table :missaos end end
Ruby
class AddImagemToResposta < ActiveRecord::Migration def self.up add_column :resposta, :imagem_file_name, :string add_column :resposta, :imagem_content_type, :string add_column :resposta, :imagem_file_size, :integer add_column :resposta, :imagem_updated_at, :datetime end def self.down ...
Ruby
class CreateJogadors < ActiveRecord::Migration def self.up create_table :jogadors do |t| t.string :nome t.string :senha t.timestamps end end def self.down drop_table :jogadors end end
Ruby
class AddColumnFlagPrimeiraToPergunta < ActiveRecord::Migration def self.up add_column :pergunta, :flag_primeira, :char end def self.down remove_column :pergunta, :flag_primeira end end
Ruby
class AddColumnNomeToNivel < ActiveRecord::Migration def self.up add_column :nivels, :nome, :string end def self.down remove_column :nivels, :nome end end
Ruby
class CreateNivels < ActiveRecord::Migration def self.up create_table :nivels do |t| t.string :descricao t.references :missao t.timestamps end end def self.down drop_table :nivels end end
Ruby
class CreateResposta < ActiveRecord::Migration def self.up create_table :resposta do |t| t.string :texto t.string :imagem t.string :pontos t.references :pergunta t.timestamps end end def self.down drop_table :resposta end end
Ruby
class AddAvatarToJogadors < ActiveRecord::Migration def self.up add_column :jogadors, :avatar_file_name, :string add_column :jogadors, :avatar_content_type, :string add_column :jogadors, :avatar_file_size, :integer add_column :jogadors, :avatar_updated_at, :datetime end def self.down ...
Ruby
class CreateResposta < ActiveRecord::Migration def self.up create_table :resposta do |t| t.integer :pergunta_id t.string :texto t.integer :pontos t.timestamps end end def self.down drop_table :resposta end end
Ruby
class CreateJogadas < ActiveRecord::Migration def self.up create_table :jogadas , :id => false do |t| t.string :jogador t.string :missao t.string :nivel t.string :pergunta t.string :resposta t.timestamps end end def self.down drop_table :jogadas end end
Ruby
class AddColumnEmailToJogador < ActiveRecord::Migration def self.up add_column :jogadors, :email, :string end def self.down remove_column :jogadors, :email end end
Ruby
class AddColumnNomeToMissao < ActiveRecord::Migration def self.up add_column :missaos, :nome, :string end def self.down remove_column :missaos, :nome end end
Ruby
class AddColumnPontuacaoToJogador < ActiveRecord::Migration def self.up add_column :jogadors, :pontuacao, :integer end def self.down remove_column :jogadors, :pontuacao end end
Ruby
class CreatePergunta < ActiveRecord::Migration def self.up create_table :pergunta do |t| t.string :caput t.boolean :respondida t.references :nivel t.references :pergunta t.timestamps end end def self.down drop_table :pergunta end end
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
source 'http://rubygems.org' gem 'rails', '3.0.5' #Gems adicionais gem "paperclip", "~> 2.3" #Fim da Gems adicionais # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' gem 'mysql2' gem 'activesupport' gem 'twitter' gem 'yajl-ruby' # Use unicorn as the web server # gem 'unicorn'...
Ruby
module MissaosHelper end
Ruby
module ApplicationHelper def link_to_remove_fields(name, f) f.hidden_field(:_destroy) + link_to_function(name, "remove_fields(this)") end end
Ruby
module JogandoHelper end
Ruby
module NivelsHelper end
Ruby
module JogadorsHelper def format_data (data) data.strftime("%m, %b, %Y") end end
Ruby
class Jogada < ActiveRecord::Base end
Ruby
class Respostum < ActiveRecord::Base end
Ruby
class Nivel < ActiveRecord::Base belongs_to :missao has_many :perguntas, :dependent => :destroy accepts_nested_attributes_for :perguntas validates_presence_of :nome, :message => "Campo obrigatorio!" end
Ruby
class Jogador < ActiveRecord::Base validates :nome, :presence => true, :length => { :within => 5..100 } validates :email, :presence => true, :uniqueness => true, :length => { :within => 5..100 }, :format => { :with => /^[^@][\w.-]+@[\w.-]+[.][a-z]{2,4}$/i } validates :senha, :presence => true...
Ruby
class Perguntum < ActiveRecord::Base has_many :respostum end
Ruby
class Missao < ActiveRecord::Base has_and_belongs_to_many :jogadors has_many :nivels validates_presence_of :nome, :message => "Campo obrigatorio!" end
Ruby
class Pergunta < ActiveRecord::Base belongs_to :nivel has_many :respostas, :dependent => :destroy accepts_nested_attributes_for :respostas validates_presence_of :caput, :message => "Campo obrigatorio!" end
Ruby
class Resposta < ActiveRecord::Base belongs_to :pergunta validates_presence_of :texto, :message => "Campo obrigatorio!" end
Ruby
class PerguntaController < ApplicationController # GET /pergunta # GET /pergunta.xml def index @pergunta = Perguntum.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @pergunta } end end # GET /pergunta/1 # GET /pergunta/1.xml def show @perg...
Ruby
class ApplicationController < ActionController::Base #protect_from_forgery # Pick a unique cookie name to distinguish our session data from others' session :session_key => '_untitled6_session_id' before_filter :authorize protected def secure? # Override in controller classes that should require authenticati...
Ruby
class NivelsController < ApplicationController # GET /nivels # GET /nivels.xml def index @nivels = Nivel.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @nivels } end end # GET /nivels/1 # GET /nivels/1.xml def show @nivel = Nivel.find(par...
Ruby
class RespostaController < ApplicationController # GET /resposta # GET /resposta.xml def index @resposta = Respostum.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @resposta } end end # GET /resposta/1 # GET /resposta/1.xml def show @resp...
Ruby
class TwitterClient require "rubygems" require "twitter" require "yajl" Twitter.configure do |config| config.consumer_key = "PJhYbG9PYW7715MxoJelg" config.consumer_secret = "c8bxNaWoX3rHvwYfApUFbAJIDK1dxfaCSzP8Xp8" config.oauth_token = "291999995-mPFFsmvFhTqBdAwrXbX5QvPFHUlfRayQr65l24ko" config.oauth_to...
Ruby
class LoginController < ApplicationController def login render :action => "login" end end
Ruby
class JogadorsController < ApplicationController # GET /jogadors # GET /jogadors.xml def index @jogadors = Jogador.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @jogadors } end end # GET /jogadors/1 # GET /jogadors/1.xml def show @...
Ruby
class MissaosController < ApplicationController # GET /missaos # GET /missaos.xml def index @missaos = Missao.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @missaos } end end # GET /missaos/1 # GET /missaos/1.xml def show @missao = Mi...
Ruby