This file contains hidden or 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
1. С помощью каких комбинаций клавиш в текстовых редакторах vi или vim скопировать в буфер 4 строки, начиная со строки, где находится курсор? | |
2. Вы в bash запустили команду echo $[5/2]. Какой будет результат? | |
3. В bash вы хотите сравнить два числа. Какой оператор сравнения нужно применить, если нужно узнать, что первое значение больше или равно второму? | |
4. Вам нужно запустить web-сервер Apache на порту 3128. С помощью какой директивы в конфигурационном файле это можно сделать? | |
5. Как в Linux узнать текущий рабочий каталог процесса с pid = 4556? | |
6. Как в Unix посмотреть какие файлы или устройства использует процесс с pid = 85003? | |
7. Какие из перечисленных типов хранилищ в MySQL поддерживают транзакционность: MyISAM, Memory, InnoDB, Archive, NDB, CSV? | |
8. Как в PostgreSQL очистить файлы баз данных от уже удалённых записей? | |
9. Как очистить лог-файл /var/log/log, открытый работающим процессом? | |
10. Вы зашли на сервер с Linux с помощью ssh. Как перегрузить этот сервер по sysrq-b? |
This file contains hidden or 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
take5([A,B,C,D,E|L]) -> [A*B*C*D*E]; | |
take5(_) -> []. | |
take5(Result, []) -> Result; | |
take5(Result, L=[H|T]) -> take5(take5(L) ++ Result,T). | |
problem8() -> | |
L = "731671765313306249192251196744265747423553491949349698352031277450632623957831801698480186947885184385861560789112949495459501737958331952853208805511125406987471585238630507156932909632952274430435576689664895044524452316173185640309871112172238311362229893423380308135336276614282806444486645238749303589072962904915604407723907138105158593079608667017242712188399879790879227492190169972088809377665727333001053367881220235421809751254540594752243525849077116705560136048395864467063244157221553975369781797784617406495514929086256932197846862248283972241375657056057490261407972968652414535100474821663704844031998900088952434506585412275886668811642717147992444292823086346567481391912316282458617866458359124566529476545682848912883142607690042242190226710556263211111093705442175069416589604080719840385096245544436298123098787992724428490918884580156166097 |
This file contains hidden or 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
is_palindrome([]) -> true; | |
is_palindrome([_|_=[]]) -> true; | |
is_palindrome(L) when is_integer(L) -> is_palindrome(erlang:integer_to_list(L)); | |
is_palindrome(L) -> L == lists:reverse(L). | |
product_palindrome(A) -> [A * B || B <- lists:seq(A + 1, 999)]. | |
problem4() -> | |
L = [product_palindrome(A) || A <- lists:seq(100, 998)], | |
L1 = lists:filter(fun(I) -> is_palindrome(I) end, lists:flatten(L)), |
This file contains hidden or 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
// The Y combinator, applied to the factorial function | |
function factorial(proc) { | |
return function (n) { | |
return (n <= 1) ? 1 : n * proc(n-1); | |
} | |
} | |
function Y(outer) { | |
function inner(proc) { |
This file contains hidden or 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
define [ | |
'vendor/backbone', | |
'vendor/mustache' | |
], (_Backbone, Mustache) -> | |
NestedSelect = {} | |
NestedSelect.Controller = Backbone.Model.extend | |
NestedSelect.View = Backbone.View.extend | |
events: |
This file contains hidden or 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
# encoding: utf-8 | |
require 'open-uri' | |
url = "http://ru.wikipedia.org/w/index.php?title=%D0%A1%D0%BF%D0%B8%D1%81%D0%BE%D0%BA_%D0%BC%D0%B5%D1%82%D1%80%D0%BE%D0%BF%D0%BE%D0%BB%D0%B8%D1%82%D0%B5%D0%BD%D0%BE%D0%B2&action=raw" | |
wiki = open(url).read | |
result = wiki.lines.map { |line| | |
next unless line.start_with?('*') | |
#* [[Лондон]] ([[1863]]) — [[Лондонский метрополитен]] — 11 линий, 408 км, 260 станций | |
This file contains hidden or 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
## <%= javascript_include_tag 'require', 'data-main' => '/assets/setup' %> | |
requirejs.config | |
baseUrl: '/assets' | |
shim: | |
'jquery': | |
exports: '$' | |
'jquery_ujs': | |
deps: ['jquery'] | |
'twitter/bootstrap': |
This file contains hidden or 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 Mongoid | |
module CounterCache | |
extend ActiveSupport::Concern | |
included do | |
end | |
module ClassMethods | |
def counter_cache(name, counter_field = nil) | |
counter_field ||= "#{self.name.underscore.pluralize}_counter" |
This file contains hidden or 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 'nokogiri' | |
require 'active_support/all' | |
def traverse(nodes, tabs = 0) | |
nodes.each do |node| | |
unless node.is_a? Nokogiri::XML::Element | |
if node.is_a?(Nokogiri::XML::Text) | |
puts ' ' * tabs + node.content.sub(/^\s+/, '').inspect if node.content !~ /^\s+$/ | |
end | |
next |
This file contains hidden or 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
# encoding: utf-8 | |
def parse_date(s) | |
map = {'ЯНВ' => 1, 'ФЕВ' => 2, 'МАР' => 3, 'АПР' => 4, 'МАЙ' => 5, 'ИЮН' => 6, 'ИЮЛ' => 7, 'АВГ' => 8, 'СЕН' => 9, 'ОКТ' => 10, 'НОЯ' => 11, 'ДЕК' => 12} | |
s =~ /^(\d+)(.+?)(\d+)$/ | |
Date.new($3.to_i + 2000, map[$2], $1.to_i) | |
end | |
require 'csv' | |
str = CSV.generate do |csv| | |
while line = gets |