Skip to content

Instantly share code, notes, and snippets.

************************************************************************
Imagina que estamos implementando una tienda online, que vende solo 3 productos:
Codigo | Nombre | Precio
_______________________________
AM | Agua mineral | 3.11€
AC | Aceite | 5.00€
CA | Cafe | 11.23€
class PrimeNumberGenerator
def initialize
@list = []
end
def next
prime = next_prime
@list.push prime
prime
end
= render 'web/facebook_connect'
%code
= IO.readlines('app/views/web/_facebook_connect.html.haml').join
alias abundle="azk shell -c bundle"
arake() { cmd="bundle exec rake $@"; azk shell -c $cmd; }
arails() { cmd="bundle exec rails $@"; azk shell -c $cmd; }
alias grubocop="git ls-files -m |xargs rubocop"
class SimplePasswordGenerator
WORDS = %w(perro gato hormiga sapo lagarto caracol melocoton hocico canguro)
def self.generate(min_size = 10, max_size = nil)
pass = sample_w_number
pass += sample_w_number while pass.size < min_size
pass.slice!(0, max_size) if max_size
pass
end
OFFER_TYPES =
{
co: OFFER_TYPE_COLOMBIA,
mx: OFFER_TYPE_COLOMBIA
}
DEFAULT_TYPE = :mx
def self.trading_account_offer_type(user)
country = I18n.locale || user.pais.codigo_iso.to_sym || DEFAULT_TYPE
OFFER_TYPES[country]
FROM ruby:2.2.0
RUN apt-get update -qq && apt-get install -y build-essential nodejs npm nodejs-legacy vim
RUN npm install -g phantomjs
WORKDIR /tmp
ADD Gemfile Gemfile
ADD Gemfile.lock Gemfile.lock
RUN bundle install
require 'test_helper'
class RubocopTest < ActiveSupport::TestCase
describe 'when run over the app' do
it 'has a clean run' do
cli = RuboCop::CLI.new
result = cli.run(%w(--rails))
value(result).must_equal 0
end
end
#!/usr/bin/env ruby
# encoding: UTF-8
#
# LearnRubyByExample:
#
# Ruby is a highly expressive programming language.
# Testing software is an expressive way to communicate how it works.
#
# In the middle of a night awake for allergy and insomnia, and some days after the 1st _why day,
# I've tried to combine Ruby and testing to help teaching ruby with some goals in mind:
class EquilibriumPoint
ERROR_CODE = -1
def initialize(arr)
@arr = arr
end
def get_point
indexes_without_edges.each do |index|
return index if equilibrium_point?(index)