Skip to content

Instantly share code, notes, and snippets.

View szymon-przybyl's full-sized avatar

Szymon Przybył szymon-przybyl

View GitHub Profile
@szymon-przybyl
szymon-przybyl / en.yml
Created February 13, 2011 21:15
what should i type here? maybe some secret code?
activerecord:
attributes:
user:
email: 'Email address'
password: 'Password'
password_confirmation: 'Confirm password'
name: 'Your name'
errors:
club:
similar_colors: 'You have to choose two different colors'
Error during failsafe response: deadlock; recursive locking
<internal:prelude>:8:in `lock'
<internal:prelude>:8:in `synchronize'
/home/szymon/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/buffered_logger.rb:101:in `flush'
/home/szymon/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/buffered_logger.rb:125:in `auto_flush'
/home/szymon/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/buffered_logger.rb:66:in `add'
/home/szymon/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/buffered_logger.rb:77:in `fatal'
/home/szymon/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_dispatch/middleware/show_exceptions.rb:132:in `block in log_error'
/home/szymon/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/deprecation/reporting.rb:16:in `silence'
/home/szymon/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_dispatch/middleware/show_exceptions.rb:128:in `log_error'
validate :validate_colors
def validate_colors
pattern = /^[\da-f]{6}$/
primary_status = primary_color =~ pattern
secondary_status = secondary_color =~ pattern
errors.add(:primary_color, @@default_error_messages[:format]) unless primary_status
errors.add(:secondary_color, @@default_error_messages[:format]) unless secondary_status
if primary_status && secondary_status
if Color.similar?(primary_color, secondary_color)
When /^I create a movie Caddyshack in the Comedy genre$/ do
visit movies_path
click_link 'Add Movie'
fill_in 'Title', :with => 'Caddyshack'
select '1980', :from => 'Release Year'
check 'Comedy'
click_button 'Save'
end
class MoviesController < ApplicationController
def index
end
def new
@movie = Movie.create
@genres = Genre.all
end
def create
= form_for(@movie) do |f|
= f.label :title
= f.text_field :title
= f.label :release_year
= f.select :release_year, (1900..2011).to_a.map(&:to_s)
- @genres.each do |genre|
%label
=h genre.name
= check_box_tag 'genres[]', genre.id
= f.submit 'Save'
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
# It is recommended to regenerate this file in the future when you upgrade to a
# newer version of cucumber-rails. Consider adding your own code to a new file
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
# files.
require 'uri'
require 'cgi'
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
def self.roots
where(:parent_id => nil)
end
new Ajax.Request('https://maps.googleapis.com/maps/api/place/autocomplete/json', {
method: 'get',
parameters: {
language: 'pl',
input: 'Polichno',
sensor: true,
key: 'ABQIAAAAHyX2ujLFqkeXszJQ65ZPbhQCULP4XOMyhPd8d_NrQQEO8sT8XBQKE5E92FkCP2ATUaYPiLb3YFfVzg'
},
onSuccess: function(transport, json) {
alert(json ? Object.inspect(json) : 'no JSON object');
class LocatorController < ApplicationController
def autocomplete
require 'net/http'
require 'net/https'
url = URI.parse 'https://maps.googleapis.com/maps/api/place/autocomplete/json?language=pl&input=Polichno&sensor=false&key=ABQIAAAAHyX2ujLFqkeXszJQ65ZPbhT2yXp_ZAY8_ufC3CFXhHIE1NvwkxTCcRPSPSwcyYGhNTuA3d46XxgyQg'
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
req = Net::HTTP::Get.new(url.path)
res = http.request(req)
puts res