This file contains hidden or 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
#!/usr/bin/env ruby | |
require 'net/http' | |
require 'uri' | |
TEST_URL = URI.parse('http://nazva.net/logic_test5/') | |
def correct?( q, a) | |
response = Net::HTTP.post_form( TEST_URL, { "q#{q}" => "#{q}#{a}"} ) | |
response.body.include? '>1<' | |
end |
This file contains hidden or 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
# Вынес из content_object без изменений. переписвать страшновато | |
module Rateable | |
def self.included(base) | |
base.extend ClassMethods | |
base.after_create :increment_user_rating | |
end | |
# рейтинг объектов | |
def rate(user, value) |
This file contains hidden or 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
ru: | |
devise: | |
sessions: | |
link: 'Войти' | |
signed_in: 'Вы вошли в систему.' | |
signed_out: 'Вы вышли из системы.' | |
unauthenticated: 'Необходимо войти в систему или зарегистрироваться.' | |
unconfirmed: 'Необходимо подтвердить адрес электронной почты.' | |
locked: 'Ваша учетная запись заблокирована.' | |
invalid: 'Неверная учетная запись или пароль.' |
This file contains hidden or 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
class CatalogueController < ApplicationController | |
@@rows_on_page = 50 | |
@@companies_on_page = 20 | |
def firms | |
# Возвращаем "304 Not Modified" если страница не устарела | |
if industry.cached_level >= 2 || industry.leaf? | |
if params[:format] != 'xls' | |
# если выводится список компаний (причем не в ExCel) |
This file contains hidden or 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
-- | |
-- PostgreSQL database dump | |
-- | |
SET statement_timeout = 0; | |
SET client_encoding = 'UTF8'; | |
SET standard_conforming_strings = off; | |
SET check_function_bodies = false; | |
SET client_min_messages = warning; | |
SET escape_string_warning = off; |
This file contains hidden or 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
class Message < ActiveRecord::Base | |
# обновляет updated_at у родительского сообщения, нужно для сортировки | |
belongs_to :parent, :class_name => "Message", :touch => true | |
belongs_to :sender, :class_name => "User" | |
belongs_to :recipient, :class_name => "User" | |
has_many :messages, :foreign_key => :parent_id, :dependent => :delete_all | |
default_scope order('created_at desc') | |
scope :threads, where(:parent_id => nil) | |
scope :unread, where(:unread => true) |
This file contains hidden or 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
class Message | |
include DataMapper::Resource | |
property :id, Serial | |
property :subject, String | |
property :body, Text | |
property :unread, Boolean, :default => true, :required => true | |
property :created_at, DateTime | |
property :updated_at, DateTime |
This file contains hidden or 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
From f1a4da7b54468f815a8478b774da1e0fe47ff0d2 Mon Sep 17 00:00:00 2001 | |
From: codesnik <[email protected]> | |
Date: Sat, 6 Mar 2010 23:54:38 +0300 | |
Subject: [PATCH] migrates to datamapper | |
--- | |
Gemfile | 71 ++++++++---- | |
Gemfile.lock | 174 +++++++++++++++++++++-------- | |
app/controllers/application_controller.rb | 2 +- | |
app/controllers/messages_controller.rb | 26 ++--- |
This file contains hidden or 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
# должно помочь с кириллицей в .to_yml | |
ruby -lpe 'gsub!(/\\x(..)/){ "%c" % $1.to_i(16) }' |
This file contains hidden or 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
begin | |
require "rubygems" | |
require "bundler" | |
rescue LoadError | |
raise "Could not load the bundler gem. Install it with `gem install bundler`." | |
end | |
if Gem::Version.new(Bundler::VERSION) <= Gem::Version.new("0.9.24") | |
raise RuntimeError, "Your bundler version is too old." + | |
"Run `gem install bundler` to upgrade." |