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
alias ggrb='grb --committer-date-is-author-date origin/$(git_current_branch)' |
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
# Put it to custom folder of ohmyzsh | |
# Open recent file of capybara screenshots | |
function ole(){ | |
local NUMBER=1 | |
if ! [ -z $1 ]; then | |
NUMBER=$1 | |
fi | |
open tmp/capybara/*.png(On[$NUMBER]) | |
} |
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
$ file -b --mime-type 'Title_Of_Word_File.doc' | |
ERROR: (null) | |
$ file --version | |
file-5.09 | |
magic file from /etc/magic:/usr/share/misc/magic | |
$ apt-get update | |
$ apt-get install file |
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
<%= render 'subpartial' %> | |
<%= @subpartial_instance_variable %> |
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
class ActiveRecord::Base | |
def self.raw_pluck(*args) | |
sql = connection.unprepared_statement { select(args).to_sql } | |
connection.execute(sql).to_a | |
end | |
end |
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
def self.percent_by_prices(previous_price, current_price) | |
return 0 if previous_price.nil? || previous_price.zero? | |
res = (((current_price.to_f/previous_price.to_f) - 1) * 100).round | |
res = self.signum(current_price - previous_price) if res.zero? | |
res | |
end | |
def self.signum(number) | |
case | |
when number > 0 |
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
def listed_date_links(feed_search, since_last_visit = false) | |
['Any', FeedSearch::SINCE_LAST_VIEW_VALUE, *FeedSearch::LAST_DAYS_VALUES].each do |col| | |
if col == current_listed_date_column(feed_search, since_last_visit).to_s | |
concat content_tag(:div, title_listed_date(col), :class => 'active') | |
else | |
concat link_to(title_listed_date(col), '#', :column_name => col, :class => 'subheader_link listed_date_column') | |
end | |
end | |
end |
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
class Feed < ActiveRecord::Base | |
scope :searchable, where(some_conditions) | |
scope :matchable, lambda { | |
where("url in | |
(SELECT du.url from | |
(SELECT url, count(*) cc | |
FROM feeds | |
WHERE (#{Feed.searchable_conditions}) | |
GROUP by url |
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
def create_listing_by_url(url, who_creates_listing) | |
return { } if url.match(UrlsProcessor::URL_WITH_DOMAIN_ONLY) | |
initial_url = url | |
res = create_listing_matched_to_feed_by_url(url, who_creates_listing, initial_url) | |
return res if res | |
res = Listing.create_empty_result_hash | |
source_info = Scraper::Manager.detect_top_level_source(url) | |
unless source_info[:source] | |
res[:not_found] << '' # it's needed to make res[:not_found] not empty array |