Skip to content

Instantly share code, notes, and snippets.

View be9's full-sized avatar

Oleg Dashevskii be9

View GitHub Profile
@be9
be9 / gist:10747
Created September 14, 2008 18:51
#!/usr/bin/env ruby
require 'rubygems'
require 'dm-core'
require 'dm-is-list'
require 'pp'
class Participation
include DataMapper::Resource
property :id, Serial
@be9
be9 / gist:12491
Created September 24, 2008 05:47 — forked from anonymous/gist:12490
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;
}
@be9
be9 / gist:15281
Created October 7, 2008 12:04
Modula-2 lists
MODULE struc;
IMPORT SWholeIO;
FROM Storage IMPORT ALLOCATE, DEALLOCATE;
TYPE
PNode = POINTER TO Node;
Node = RECORD
number : CARDINAL;
next : PNode;
@be9
be9 / gist:15282
Created October 7, 2008 12:17
Modula-2 Files
MODULE cat;
IMPORT StreamFile, ChanConsts, STextIO, TextIO, IOConsts, IOChan;
VAR
fi : StreamFile.ChanId;
fname : ARRAY [0..255] OF CHAR;
res : ChanConsts.OpenResults;
ch : CHAR;
class StubErrors
def on(*args); [] end
end
class MyObject
# .......
def errors; StubErrors.new end
end
<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>
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
@be9
be9 / Console.def
Created December 9, 2008 13:07
Console library for Modula-2
DEFINITION MODULE Console;
IMPORT Windows;
TYPE ATTRIBUTE = Windows.CHAR_ATTRIBUTES_SET;
EVENT = Windows.INPUT_RECORD;
(* colors *)
CONST
FG_BLACK = ATTRIBUTE{}; (* 0 *)
Функционал: Регистрация
Чтобы входить в систему под своим логином,
будучи в настоящий момент анонимным пользователем,
я хочу зарегистрироваться в системе.
Сценарий: Страница регистрации
Сначала я не залогинен
И я зашел на главную
Если я кликаю на "Регистрация"
То я должен увидеть "Регистрация"
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)