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
# Класс создатель объектов Url и связанных сущностей. | |
class UrlCreator | |
attr_reader :uri, :domain, :url_path, :query_string, :url | |
# Инициирует модель Url на основе полного URL. | |
# | |
# @param [String] full_url какой-то URL (http://www.linux.org.ru/forum/talks/8623652) | |
# | |
def initialize(full_url) | |
@uri = URI.parse(full_url) |
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
ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}[%{$fg[green]%}" | |
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}]" | |
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}*%{$reset_color%}" | |
ZSH_THEME_GIT_PROMPT_CLEAN="" | |
#Customized git status, oh-my-zsh currently does not allow render dirty status before branch | |
git_custom_status() { | |
local cb=$(current_branch) | |
if [ -n "$cb" ]; then | |
echo "$(parse_git_dirty)%{$fg_bold[yellow]%}$(work_in_progress)%{$reset_color%}$ZSH_THEME_GIT_PROMPT_PREFIX$(current_branch)$ZSH_THEME_GIT_PROMPT_SUFFIX" |
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
# controller | |
class UsersController < ApplicationController | |
def send_recovery | |
user = User.find_by(email: params[:email].to_s.downcase) | |
if user.nil? | |
flash[:message] = t('email_not_found') | |
redirect_to recover_form_users_path | |
else | |
send_recovery_code user | |
redirect_to recover_users_path |
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
\set QUIET 1 | |
\x auto | |
\timing | |
\set PROMPT1 '%[\x1b[33m%]%n%[\x1b[0m%]@%[\x1b[32m%]%/%[\x1b[0m%] > ' | |
\pset null '(null)' | |
\set QUIET 0 |
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
git log --pretty=format:'%C(auto)%h%d%Creset %s %C(green)(%cr) %C(bold blue)<%an>' --graph --all |
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 'eventmachine' | |
require 'awesome_print' | |
class Channel | |
def initialize | |
@sockets = [] | |
end | |
def subscribe(socket) | |
@sockets << socket |
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 defaultify(hash) | |
hash.default_proc = ->(hash, key) { | |
hash[key] = Hash.new | |
} | |
end | |
class UsersController < ActiveRecord::Base | |
def create | |
defaultify(hash) | |
# code |
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 fibonacci(numbers_count) | |
sequence = Enumerator.new do |yielder| | |
current_number, next_number = 0, 1 | |
loop do | |
yielder << current_number | |
current_number, next_number = next_number, current_number + next_number | |
end | |
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
module PB | |
module SocialNetwork | |
class Twitter | |
include PB::SocialNetwork::Base | |
def initialize(token) | |
@token = token | |
end | |
def update_profile(params = {}) |
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
# encoding: utf-8 | |
class Payment | |
RATE = 3.8 | |
attr_accessor :previous, :current | |
def initialize(params = {}) | |
@previous = params.delete(:previous) | |
@current = params.delete(:current) | |
end |