Skip to content

Instantly share code, notes, and snippets.

require 'ostruct'
require 'pry/config'
class Pry
# The RC Files to load.
HOME_RC_FILE = ENV["PRYRC"] || "~/.pryrc"
LOCAL_RC_FILE = "./.pryrc"
# @return [Hash] Pry's `Thread.current` hash
require 'ostruct'
require 'pry/config'
class Pry
# The RC Files to load.
HOME_RC_FILE = ENV["PRYRC"] || "~/.pryrc"
LOCAL_RC_FILE = "./.pryrc"
# @return [Hash] Pry's `Thread.current` hash
@chikadance
chikadance / pager.rb
Created December 21, 2013 07:20
a desc
require 'pry/terminal'
# A pager is an `IO`-like object that accepts text and either prints it
# immediately, prints it one page at a time, or streams it to an external
# program to print one page at a time.
module Pry::Pager
class StopPaging < StandardError
end
# Send the given text through the best available pager (if `Pry.pager` is
@chikadance
chikadance / cli.rb
Created December 21, 2013 07:41
guard options
require 'thor'
require 'guard'
require 'guard/version'
require 'guard/dsl_describer'
require 'guard/guardfile'
module Guard
# Facade for the Guard command line interface managed by [Thor](https://github.com/wycats/thor).
@chikadance
chikadance / commander.rb
Created December 21, 2013 08:36
pause guard listen file to avoid stuck on type
module Guard
module Commander
# Start Guard by evaluating the `Guardfile`, initializing declared Guard plugins
# and starting the available file change listener.
# Main method for Guard that is called from the CLI when Guard starts.
#
# - Setup Guard internals
# - Evaluate the `Guardfile`
@chikadance
chikadance / ex1.rb
Created December 21, 2013 09:43
simple before after hook
require 'active_support/core_ext'
module M
end
class C
def m
puts 'm'
end
@chikadance
chikadance / session.rb
Created December 23, 2013 05:03
capybara dsl
module Capybara
##
#
# The Session class represents a single user's interaction with the system. The Session can use
# any of the underlying drivers. A session can be initialized manually like this:
#
# session = Capybara::Session.new(:culerity, MyRackApp)
#
# The application given as the second argument is optional. When running Capybara against an external
@chikadance
chikadance / ex2.rb
Created December 24, 2013 09:59
basic celluloid example
require 'celluloid'
require 'open-uri'
require 'cgi'
require 'benchmark'
module Enumerable
def pmap(&block)
futures = map do |elem|
puts "future"
Celluloid::Future.new(elem, &block)
@chikadance
chikadance / ex1.rb
Created December 28, 2013 03:35
capybara uses selenium driver and celluloid
require 'bundler/setup'
require 'pry'
require 'celluloid'
require 'capybara/dsl'
require 'capybara/webkit'
require 'faker'
require 'cgi'
Capybara.register_driver :selenium do |app|
@chikadance
chikadance / index.html.erb
Created December 28, 2013 09:42
fix will_paginate/draper
<div class="row">
<div class="col-xs-8 ">
<div class="post">
<ul class="list-unstyled">
<% @posts.each do |post| %>
<div class="title">
<li class="text-left">
<h4><%= link_to post.title, post, class: '' %></h4>
</li>
<li>