This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe Classroom do | |
subject(:classroom) { Classroom.new } | |
context "when the children are rowdy" do | |
before(:each, run: true) do | |
classroom.throw_pizza_party | |
end | |
it "example1", run: :true | |
it "example2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'httparty' | |
class SlackRuby | |
include HTTParty | |
base_uri 'slack.com/api' | |
def initialize(token) | |
@token = token | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# == Schema Information | |
# | |
# Table name: categories | |
# | |
# id :integer(4) not null, primary key | |
# name :string(255) | |
# description :text | |
# created_at :datetime | |
# updated_at :datetime | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Populator.words(5) # gera 5 palavras aleatoriamente e insere um espaço entre elas | |
Populator.words(1..3) # gera entre uma e três palavras aleatoriamente | |
Populator.sentences(3) # gera 3 frases | |
Populator.paragraphs(2) # gera 2 paragrafos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :db do | |
desc "Popula base de dados" | |
task :populate => :environment do | |
require 'populator' | |
Category.populate 30 do |category| | |
category.name = Populator.words(1..3).titleize | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>> require 'populator' | |
=> [] | |
>> Category.count | |
=> 0 | |
>> Category.populate(10) { |category| category.name = Populator.words(1..3).titleize } | |
=> {} | |
>> Category.count | |
=> 10 | |
>> Category.first | |
=> #<Category id: 1, name: "Fuga Debitis Temporibus", created_at: "2009-06-13 14:17:24", updated_at: "2009-06-13 14:17:24"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Atualiza as informações do banco de dados e os arquivos no servidor de acordo com os styles definidos no model | |
rake paperclip:refresh CLASS=SeuModel | |
# Atualiza somente as informações do banco de dados | |
rake paperclip:refresh:metadata CLASS=SeuModel | |
# Atualiza somente os arquivos no servidor, seguindo os styles definidos no model | |
rake paperclip:refresh:thumbnails CLASS=SeuModel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Web::AdsHelper | |
def add_picture(form) | |
link_to_function 'Adicionar outra imagem' do |page| | |
form.fields_for :pictures, Picture.new, :child_index => 'NEW_RECORD' do |f| | |
html = render(:partial => 'fields_pictures', :locals => {:f => f}) | |
# caso use prototype, inserir a linha abaixo | |
# $('pictures').insert({ bottom: "#{ escape_javascript html }".replace(/NEW_RECORD/g, new_picture_id) }); | |
page << %{ | |
var new_picture_id = new Date().getTime() | |
$('#pictures').after("#{escape_javascript html}".replace(/NEW_RECORD/g, new_picture_id)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/models/quina.rb | |
class Quina | |
def self.gerar_numeros | |
resultado = (1..8).map { (1..10).map } | |
end | |
end | |
# app/controllers/quina_controller.rb | |
class QuinaController < ApplicationController | |
def index |
OlderNewer