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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'dm-core' | |
require 'dm-is-list' | |
require 'pp' | |
class Participation | |
include DataMapper::Resource | |
property :id, Serial |
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
MODULE cat; | |
IMPORT StreamFile, ChanConsts, STextIO, TextIO, IOConsts, IOChan; | |
VAR | |
fi : StreamFile.ChanId; | |
fname : ARRAY [0..255] OF CHAR; | |
res : ChanConsts.OpenResults; | |
ch : CHAR; | |
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
DEFINITION MODULE Console; | |
IMPORT Windows; | |
TYPE ATTRIBUTE = Windows.CHAR_ATTRIBUTES_SET; | |
EVENT = Windows.INPUT_RECORD; | |
(* colors *) | |
CONST | |
FG_BLACK = ATTRIBUTE{}; (* 0 *) |
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) |
OlderNewer