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 declOfNum(number, titles) { | |
cases = [2, 0, 1, 1, 1, 2]; | |
return titles[ (number%100>4 && number%100<20)? 2 : cases[(number%10<5)?number%10:5] ]; | |
} | |
use: | |
declOfNum(count, ['найдена', 'найдено', 'найдены']); |
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
# put this code at ~/.caprc | |
# install libnotify-bin | |
# run deploy | |
# profit :) | |
def notify(message, body, urgency, icon = :info) | |
system("notify-send --urgency=#{urgency} --icon=#{icon} '#{message}' '#{body}'") | |
end | |
on :exit do |
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
# system | |
[[ -s '/usr/local/lib/rvm' ]] && source '/usr/local/lib/rvm' | |
# single | |
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" |
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
it 'should be work with asserts' do | |
acl = YaAcl::Builder.build do | |
roles do | |
role :admin | |
role :another_user | |
role :editor | |
role :operator | |
end | |
asserts do |
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
require 'formula' | |
class Vim <Formula | |
url 'ftp://ftp.vim.org/pub/vim/unix/vim-7.3.tar.bz2' | |
homepage 'http://www.vim.org/' | |
md5 '5b9510a17074e2b37d8bb38ae09edbf2' | |
version '7.3.135' | |
def patchlevel; 135 end | |
def features; %w(tiny small normal big huge) 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
#yml: | |
in_count_complex: | |
one: "в %{count} комплексе" | |
few: "в %{count} комплексах" | |
many: "в %{count} комплексах" | |
#view: | |
= t :in_count_complex, :count => projects.count |
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
# | |
# Requirement: delimiter ',' after each operands | |
# Example: | |
# | |
# ~> ruby polish '8,2,5,*+1,3,2,*+4,-/' | |
# result: 6 | |
# | |
class ReversePolishTypeError < StandardError; 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
$('form').on('change', 'input[type="file"]', function(e) { | |
var files = e.target.files, | |
f = files[0], | |
reader = new FileReader(), | |
t = this | |
; | |
reader.onload = (function(file) { |
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 normalize_params(params, name, v = nil) | |
name =~ %r(\A[\[\]]*([^\[\]]+)\]*) | |
k = $1 || '' | |
after = $' || '' | |
return if k.empty? | |
if after == "" | |
params[k] = v | |
elsif after == "[]" |
OlderNewer