Skip to content

Instantly share code, notes, and snippets.

desc "Launch a Capybara session in a console"
task capyconsole: :environment do
require "capybara"
require "pry"
driver = case ENV.fetch('DRIVER', 'phantomjs')
when 'phantomjs'
require "capybara/poltergeist"
Capybara.register_driver :poltergeist_debug do |app|
class FileAttachmentUploader < CarrierWave::Uploader::Base
storage :fog
end
class From
attr_accessor :original
def initialize(object)
self.original = object
end
def id
"#{original.class}-#{original.id}"
end
# Description:
# Everything is awesome.
#
# Configuration:
# HUBOT_LESS_EVERYTHINGISAWESOME
#
# Commands:
# awesome | team - reply with everything is awesome thing
module.exports = (robot) ->
class Phrase
def initialize(value)
@phrase = value
end
def word_count
Hash.new(0).tap do |count|
phrase_words.each do |word|
count[word.downcase] += 1
end
class Phrase
def initialize(value)
@phrase = value
end
def word_count
Hash.new(0).tap do |count|
@phrase.split(/[^[:alnum:]]+/).each do |word|
count[word.downcase] += 1
end
class Bob
def hey(input)
input = Input.new(input)
if input.blank?
'Fine. Be that way.'
elsif input.shouting?
'Woah, chill out!'
elsif input.question?
'Sure.'
else
I, [2013-08-19T12:53:56.685125 #90466] INFO -- : SOAP request: http://ec2e-gf-n1.connexon.com:28080/ConnexonProprietaryLocation_Service/LocationConnexonWS?wsdl
I, [2013-08-19T12:53:56.685192 #90466] INFO -- : SOAPAction: "AddLocationComplete", Content-Type: text/xml;charset=UTF-8, Content-Length: 979
D, [2013-08-19T12:53:56.685470 #90466] DEBUG -- : <?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://service.administration.connexon.com/" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Body><tns:AddLocationComplete><authentication>
<accountID>BD721DDD-7FCB-4624-9263-708ABE68DA70</accountID>
<authenticationToken>EE2F9882-B394-4696-A068-0A9BD58ED9FD</authenticationToken>
</authentication>
<addressData>
@mileszs
mileszs / parser.rb
Last active December 19, 2015 11:09
I finally wrote a script for pulling twitter usernames out of the Hacks && Happenings newsletters.
TWITTER_LINKS = /twitter\.com\/([\w\/]*)/
usernames = File.open('email.txt', 'r').readlines.map do |line|
matches = line.scan(TWITTER_LINKS).flatten
end.compact.flatten
['mileszs', '_swanson'].each { |n| usernames.delete(n) }
puts "... content from #{usernames.join(', ')}"
@mileszs
mileszs / pre-commit
Created June 25, 2013 11:02
Git pre-commit hook for prompting to remove binding.pry and debugger lines lines. (Includes a commented example of adding a check for focus in spec files.)
#!/usr/bin/env ruby
hits = []
checks = {
#'_spec\.rb$' => ['focus:[:space:]*true'],
'\.rb$' => ['binding\.pry', 'debugger']
}
# Find the names of all the filenames that have been (A)dded (C)opied or (M)odified
filenames = `git diff --cached --name-only --diff-filter=ACM`.split("\n")