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
// Solution for http://haskell98.blogspot.ru/2014/10/blog-post_10.html | |
// Results at http://haskell98.blogspot.ru/2014/10/blog-post_20.html | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <stdbool.h> | |
typedef unsigned long long int bigint; |
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
REM Usage example: | |
REM | |
REM | A | B | | |
REM --+-----+-----+ | |
REM 1 | 111 | aaa | | |
REM 2 | 222 | bbb | | |
REM 3 | 222 | ccc | | |
REM 4 | 333 | ddd | | |
REM 5 | 333 | eee | |
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
@echo OFF | |
REM watch is a GNU command-line tool that runs the specified command repeatedly | |
REM and displays the output on stdout so you can watch it change over time. | |
REM By default, the command is run every two seconds, although this is adjustable with the -n secs argument. | |
if x%1==x (call :usage %0 %* && exit /b 1) | |
if x%1==x-n ( | |
if x%2==x (call :usage %0 %* && exit /b 1) |
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
#pragma once | |
#include "../console/console.h" | |
#include <stdlib.h> | |
#include <stdio.h> | |
namespace MDS | |
{ | |
#pragma pack(push, 1) |
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
3.times do | |
puts "Hello, world!" | |
end | |
puts "Tomorrow will be " + 24.hours.from_now |
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 :application, "embplay" | |
set :user, "deployer" | |
set :deploy_to, "/home/deployer/#{application}" | |
set :use_sudo, false | |
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
class UserSession < Authlogic::Session::Base | |
acts_as_translatable_model | |
login_blank_message "не должен быть пустым" | |
login_not_found_message "не найден" | |
password_blank_message "не должен быть пустым" | |
password_invalid_message "неверный" | |
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
a = [3, 4, 5] | |
b = %w{a b c} # b = ['a', 'b', 'c'] - быстрая инициализация строковых массивов | |
a.each do |digit| | |
puts digit.to_s # конвертируем в строку (хотя тут это необязательно) | |
end | |
# поиграй с этим в irb - интерактивная консоль для ruby | |
a + b | |
a - 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
class Rate < ActiveRecord::Base | |
belongs_to :user | |
belongs_to :book | |
validates_presence_of :user, :book, :value | |
validates_numericality_of :value, | |
:only_integer => true | |
validates_inclusion_of :value, | |
:in => 1..10, | |
:message => "should be from 1 to 10" |
OlderNewer