Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

// 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;
@cypok
cypok / gist:bb6979fa535f3ab10874
Last active August 29, 2015 14:09
OpenOffice.org Calc macro ConcatenateIf: mix of CountIf and Concatenate
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 |
@cypok
cypok / watch.bat
Last active August 29, 2015 14:21
Analog of watch (GNU command-line tool) for Windows
@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)
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
#pragma once
#include "../console/console.h"
#include <stdlib.h>
#include <stdio.h>
namespace MDS
{
#pragma pack(push, 1)
3.times do
puts "Hello, world!"
end
puts "Tomorrow will be " + 24.hours.from_now
default_run_options[:pty] = true
set :application, "embplay"
set :user, "deployer"
set :deploy_to, "/home/deployer/#{application}"
set :use_sudo, false
set :scm, "git"
class UserSession < Authlogic::Session::Base
acts_as_translatable_model
login_blank_message "не должен быть пустым"
login_not_found_message "не найден"
password_blank_message "не должен быть пустым"
password_invalid_message "неверный"
end
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
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"