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
#!/usr/bin/perl | |
# ------------------------------------------------------------------------------ | |
# Напишите скрипт, получающий в качестве параметра путь к XML-файлу и выдающий | |
# на STDOUT следующее: | |
# * суммарное число букв внутри тегов, не включая пробельные символы | |
# (<aaa dd="ddd">text</aaa> - четыре буквы) | |
# * суммарное число букв нормализованного текста внутри тегов, включая пробелы | |
# * число внутренних ссылок (теги <a href="#id">) | |
# * число битых внутренних ссылок (ссылки на несуществующие ID элементов) |
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
package StrictRound; | |
# ------------------------------------------------------------------------------ | |
# Обёртка для POSIX::round. Позволяет настраивать контроль входного параметра | |
# и реакцию на ошибки. Плюс обрабатывает ',' (или что ещё) как десятичную точку. | |
# | |
# Пример: | |
# | |
# use StrictRound qw/strict_round/, { | |
# allow_undef => 1, - разрешить undef и '' |
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
#!/usr/bin/perl | |
# -------------------------------------------------------------------------------- | |
# Вход: массив слов | |
# Выход: отдельно сгруппировать слова, являющиеся анаграммами, | |
# отдельно - не являющиеся | |
# -------------------------------------------------------------------------------- | |
use Modern::Perl; | |
use utf8; | |
use DDP; |
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
#!/bin/bash | |
SRC="." | |
for FILE in $(find "$SRC" -type f -regex ".*[.]\(p.\|[it]?html\|php\|cgi\|t\|js\|s?css\|feature\|sql\|yml\|json\|txt\)$") | |
do | |
R=$(grep $'\r' "$FILE") | |
if [ -n "$R" ]; then | |
echo "$FILE" | |
TEMPFILE=$(tempfile) |
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
static const boost::regex::flag_type rx_flags = | |
boost::regex_constants::perl| | |
boost::regex_constants::icase| | |
boost::regex_constants::optimize| | |
boost::regex_constants::collate; | |
static boost::regex regex_tcp_v4("((([^:]+)?(:([^@]+))?@)?([^\\/\\?:]+)(:(\\d+))?)?(\\/([^\\?]+)?)?(\\?(.*))?$", rx_flags); | |
static boost::regex regex_tcp_v6("((([^:]+)?(:([^@]+))?@)?(\\[[:\\da-f]+\\])(:(\\d+))?)?(\\/([^\\?]+)?)?(\\?(.*))?$", rx_flags); | |
static boost::regex regex_unix("((([^:]+)?(:([^@]+))?@)?([^:?:]+)(:([^\\?]+))?)?(\\?(.*))?", rx_flags); | |
static boost::regex regex_query("([-\\w+%]+)=([^&;]*)", rx_flags); | |
static boost::regex regex_is_v6("\\[[\\:\\da-f]+\\]", rx_flags); |
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
# | |
# http://perldoc.perl.org/CORE.html#OVERRIDING-CORE-FUNCTIONS | |
# > To override a built-in globally (that is, in all namespaces), you need to | |
# > import your function into the CORE::GLOBAL pseudo-namespace at compile | |
# > time: | |
# > | |
# > BEGIN { | |
# > *CORE::GLOBAL::hex = sub { | |
# > # ... your code here | |
# > }; |
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
static bool match_here(const char* mask, const char* text); | |
static inline bool match_star(int c, const char* mask, const char* text) | |
{ | |
do { | |
if(match_here(mask, text)) | |
return true; | |
} while(*text != '\0' && (*text++ == c || c == '?')); | |
return false; |
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
#include <arpa/inet.h> | |
#include <string> | |
struct cidr; | |
static bool cidr_match(const cidr& src, const cidr& net); | |
static bool addr2cidr(const char* addr, cidr& entry); | |
/* | |
src & net can be any of: | |
"IPv4" | |
"IPv6" |
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 lp_timer_t { | |
private: | |
timer_t timerid; | |
bool started; | |
void* data; | |
struct sigevent sev; | |
struct sigaction sa; | |
struct sigaction prev; | |
struct itimerspec its; |
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
#!/usr/bin/perl | |
# Написать функцию http_get ($host, $path, $query, $timeout), которая | |
# делает http запрос на адрес http://$host/$path?$query с таймаутом $timeout. | |
# Реализация http должна быть примитивной, то есть мы расчитываем на ответ | |
# HTTP 200 OK с content-length. | |
# $query передают в функцию хешом. | |
# А также написать асинхронную версию этой функции, которая (для простоты | |
# задания) отличается тем, что пока ждет ответа занимается заполнением | |
# какого-нить массива числами и выводит на экран сколько элементов успела |