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
# -*- coding: utf-8 -*- | |
class RssFeedValidator < ActiveModel::EachValidator | |
def validates_each(record, attribute, value) | |
feed = Curl::Easy.new(url) do|curl| | |
curl.on_success validate_xml(feed, record, attribute) | |
curl.on_failure record.errors[attribute] << "remote host not avalible." | |
end | |
end | |
def validate_xml(feed, record, attribute) |
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
# -*- coding: utf-8 -*- | |
class EmailValidator < ActiveModel::EachValidator | |
def validate_each(record, attribute, value) | |
begin | |
m = Mail::Address.new(value) | |
r = m.domain && m.address == value | |
t = m.__send__(:tree) | |
r &&= (t.domain.dot_atom_text.elements.size > 1) | |
rescue Exception => e | |
r = 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
$ sudo apt-get install subversion git cmake build-essential yasm libqt4-dev kdelibs5-dev libsdl1.2-dev libsdl-image1.2-dev libxml2-dev libx264-dev libtheora-dev libxvidcore-dev libogg-dev libvorbis-dev libschroedinger-dev libmp3lame-dev libfaac-dev libfaad-dev libgsm1-dev libopencore-amrnb-dev libopencore-amrwb-dev libsamplerate0-dev libjack-dev libsox-dev ladspa-sdk swh-plugins libmad0-dev libpango1.0-dev | |
Add the following line to /etc/apt/sources.list: | |
deb http://www.deb-multimedia.org squeeze main | |
$ sudo apt-get update | |
$ sudo apt-get install deb-multimedia-keyring | |
$ sudo apt-get install libfaac-dev |
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
ssh root@host_ip | |
# если perl выдает ошибки с локалью | |
$ locale | |
$ export VAR='value' | |
$ apt-get update | |
$ apt-get -y install curl git-core python-software-properties | |
$ sudo apt-get install build-essential zlib1g-dev curl git-core sqlite3 libsqlite3-dev |
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
IP Address: somehost | |
Username: root | |
Password: root_password | |
ssh root@somehost | |
# if perl display errors aboul locale | |
locale | |
export LC_ALL="en_US.UTF-8" |
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 CarConfig | |
include ActiveSupport::Configurable | |
config_accessor :brand | |
end | |
class Car | |
attr_accessor :brand | |
def initialize | |
self.brand = self.class.config.brand |
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
<div ng-repeat="tour in tours"> | |
<h1 ng-show="tour.state=='view'">{{tour.title}}</h1> | |
<input ng-show="tour.state=='edit'" ng-model="title" /> | |
<button ng-click="editTour(tour)" ng-show="tour.state=='view'">Редактировать</button> | |
<button ng-click="saveTour(tour)" ng-show="tour.state=='edit'">Сохранить</button> | |
<button ng-click="cancelEditing(tour)" ng-show="tour.state=='edit'">Отменить</button> | |
</div> |
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 loadCountries(){ | |
$http.get('http://api.com/countries') | |
} | |
var allCountries = []; | |
// летит запрос на сервер, ждем ответа, после ответа заполняем массив | |
loadCountries().then(function(data){ | |
allCountries = data.countries | |
}) |
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
export function AutocloseDirective ($document, $timeout) { | |
'ngInject'; | |
let directive = { | |
restrict: 'A', | |
scope: { visible: "=mdAutoclose" }, | |
link: (scope) => { | |
let close = () => { | |
scope.$apply(() => {scope.visible = 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
class User | |
def test message | |
if block_given? | |
yield(message) | |
else | |
message | |
end | |
end | |
end |
OlderNewer