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
# Useage: select2("value to select", from: "label text") | |
module Capybara | |
module Select2 | |
def select2(value, options={}) | |
select_name = options[:from] | |
select2_container = first("label", text: select_name).find(:xpath, "..").find(".select2-container") | |
select2_container.find(".select2-choice").click | |
find(:xpath, "//body").find(".select2-drop li", text: value).click | |
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
Dash=(Dedent=-(Indent=1.0/0)).to_s[0...1] | |
def scan(file) | |
File.readlines(file).inject([[],[]]) do |(tokens,levels),line| | |
case (levels.last || 0) <=> (level = line[/^\s*(-\s*)?/].length) | |
when -1 then tokens << Indent; levels << level | |
when 1 then while (levels.last || 0) > level; levels.pop; tokens << Dedent; end | |
end | |
if matches = line.match(/^\s*(-\s*)?(\w+):\s*(.*)$/) | |
tokens << Dash if matches[1] |
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
# config/initializers/amqp.rb | |
require 'amqp/utilities/event_loop_helper' | |
require 'amqp/integration/rails' | |
module AMQPManager | |
def self.start | |
AMQP::Utilities::EventLoopHelper.run | |
AMQP::Integration::Rails.start do |connection| | |
connection.on_error do |ch, connection_close| | |
raise connection_close.reply_text |
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
# Public: Implementation of "Strike a match" algorithm for calculating | |
# similarity between strings. | |
# | |
# http://www.catalysoft.com/articles/StrikeAMatch.html | |
# | |
# Examples | |
# | |
# checker = StringSimilarityChecker.new('Quick brown fox') | |
# | |
# checker =~ 'quick brown ox' #=> true |
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
WEB FUNDAMENTS (САМЫЙ ОСНОВЫ) - HTML & CSS | |
http://www.codecademy.com/tracks/web | |
HTML | |
http://htmlbook.ru/samhtml | |
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
require('config/adapters/faye-adapter'); | |
export default DS.FayeAdapter.extend(); |
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
These two files should help you to import passwords from mac OS X keychains to 1password. | |
Assumptions: | |
1) You have some experience with scripting/are a power-user. These scripts worked for me | |
but they haven't been extensively tested and if they don't work, you're on your own! | |
Please read this whole document before starting this process. If any of it seems | |
incomprehensible/frightening/over your head please do not use these scripts. You will | |
probably do something Very Bad and I wouldn't want that. | |
2) You have ruby 1.9.2 installed on your machine. This comes as standard with Lion, previous | |
versions of OS X may have earlier versions of ruby, which *may* work, but then again, they |
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 'action_view' | |
module ActionView | |
module Template::Handlers | |
class NokogiriBuilder | |
class_attribute :default_format | |
self.default_format = Mime::XML | |
def call(template) | |
require 'nokogiri' |
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 Service | |
class TransactionWrapper | |
TransactionFailed = Class.new(StandardError) | |
attr_reader :sequence | |
delegate :append, :prepend, to: :sequence | |
def initialize(sequence, connection) | |
@sequence = sequence | |
@connection = connection |
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 "uri" | |
(URI::REGEXP.constants - ["PATTERN"]).each do |rc| | |
puts "#{rc}: #{URI::REGEXP.const_get(rc)}" | |
end | |
URI::REGEXP::PATTERN.constants.each do |pc| | |
puts "#{pc}: #{URI::REGEXP::PATTERN.const_get(pc)}" | |
end |
OlderNewer