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
function cool_cost(cost) { | |
cost = Number(cost); | |
c = Math.floor(cost / 1000); | |
b = String(cost % 1000); | |
while (b.length < 3) | |
b = '0' + b; | |
return c + ',' + b; | |
} |
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 struc; | |
IMPORT SWholeIO; | |
FROM Storage IMPORT ALLOCATE, DEALLOCATE; | |
TYPE | |
PNode = POINTER TO Node; | |
Node = RECORD | |
number : CARDINAL; | |
next : PNode; |
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
class StubErrors | |
def on(*args); [] end | |
end | |
class MyObject | |
# ....... | |
def errors; StubErrors.new end | |
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
<html> | |
<head> | |
<script type="text/javascript" src="jquery.js"></script> | |
<script type="text/javascript"> | |
$(function() { | |
//$('#victim').hide().fadeIn().pause(1000).remove(); | |
$('#victim').remove(); | |
}); | |
</script> | |
</head> |
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
def quick(a) | |
return a if a.min == a.max | |
m = a[rand(a.size)] | |
quick( a.select { |i| i <= m } ) + quick( a.select { |i| i > m } ) | |
end | |
describe "Quicksort" do | |
it "should sort an empty array" do | |
quick([]).should == [] | |
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
Функционал: Регистрация | |
Чтобы входить в систему под своим логином, | |
будучи в настоящий момент анонимным пользователем, | |
я хочу зарегистрироваться в системе. | |
Сценарий: Страница регистрации | |
Сначала я не залогинен | |
И я зашел на главную | |
Если я кликаю на "Регистрация" | |
То я должен увидеть "Регистрация" |
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
class Blah < ApplicationController | |
access_control do | |
default :deny | |
allow anonymous # аналогично allow nil - пустить анонима | |
allow :admin # проверяет по глобальной роли | |
allow :creator, :of => Ruby # проверяет по роли на класс | |
allow :employed, :by => :company # current_user.has_role? :employed, @company | |
allow do | |
current_user.has_role?('lover', Dog) && current_user.has_role?('hater', Cat) |
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
default_run_options[:pty] = true | |
set :use_sudo, false | |
set :user, "deploy" | |
set :application, "flats-hunter.ru" | |
set :deploy_to, "/home/deploy/#{application}" | |
# GIT | |
set :scm, :git |
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
<h1>Войти в систему</h1> | |
<% form_for @account_session, :url => account_session_path do |f| %> | |
<%= f.error_messages :header_message => 'Ошибка входа' %> | |
<%= f.label :email, "E-mail" %><br /> | |
<%= f.text_field :email %><br /> | |
<br /> | |
<%= f.label :password, "Пароль" %><br /> | |
<%= f.password_field :password %><br /> | |
<br /> |
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
#include <stdio.h> | |
#define USD_RATE 36.0 | |
double usd2rur(double usd) | |
{ | |
return usd * USD_RATE; | |
} | |
double rur2usd(double rur) |