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
<aside> | |
<div class="widget"> | |
<h5 class="widget-title"> | |
<p></p> | |
</div> | |
<!-- other widgets --> | |
</aside> | |
<!-- CSS: |
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
# categories - массив объектов Category с полем name, по которому идет алфивитная разбивка. | |
# Сначала выводятся все буквенные названия, потом все остальное | |
def categories_by_alphabet(categories) | |
letter_sets = {} | |
other = [] | |
categories.each do |category| | |
first_letter = category.name.mb_chars.downcase.first.to_s |
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 group_header(text, group_name = :main, &block) | |
@group_headers ||= {} | |
if @group_headers[group_name] != text | |
@group_headers[group_name] = text | |
block_given? ? yield(text) : text | |
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
def box(*args, &block) | |
options = args.extract_options! | |
content = block_given? ? capture(&block) : args.shift | |
result = '<div class="box">%s</div>' % content | |
result.html_safe! | |
block_given? ? concat(result) : result | |
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
# RAILS_ROOT/lib/jobs/queue.rb | |
module Jobs | |
module Queue | |
mattr_accessor :logger | |
def enqueue(*args) | |
Resque.enqueue(self, *args) | |
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
mysql> desc covers; | |
+----------------------+--------------+------+-----+---------+----------------+ | |
| Field | Type | Null | Key | Default | Extra | | |
+----------------------+--------------+------+-----+---------+----------------+ | |
| id | int(11) | NO | PRI | NULL | auto_increment | | |
| page_id | int(11) | YES | MUL | NULL | | | |
| item_id | int(11) | YES | MUL | NULL | | | |
| performed | tinyint(1) | YES | | 0 | | | |
| cover_file_name | varchar(255) | YES | | NULL | | | |
| cover_content_type | varchar(255) | YES | | NULL | | |
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
# Query_time: 21.994271 Lock_time: 0.000081 Rows_sent: 4 Rows_examined: 4 Rows_affected: 0 Rows_read: 4 | |
SELECT * FROM `covers` WHERE (`covers`.`id` IN (20104,11172,124710,472793)); |
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
# Put this to ~/.irbrc (no extension) | |
require "rubygems" | |
require 'irb/completion' | |
ARGV.concat [ "--readline", "--prompt-mode", "simple" ] | |
# IRB & Readline hostory | |
module Readline | |
module History |
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 Rack | |
module Middleware | |
class BasicAuth | |
def initialize(app, options = {}) | |
@app = app | |
@options = options | |
end | |
def call(env, options = {}) | |
unless env['REMOTE_USER'] |
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
# Add this your environment.rb or environment/*.rb file | |
config.middleware.use(::Rack::Middleware::BasicAuth, | |
:username => "myuser", | |
:password => "my$uperpa$$vvord", | |
:domain => "mydomain.com" | |
) |