Skip to content

Instantly share code, notes, and snippets.

View ryanjones's full-sized avatar

Ryan Jones ryanjones

View GitHub Profile
@ryanjones
ryanjones / Monitore.rb
Created April 7, 2011 14:54
Convore + IRC + cinchrb
## Setting up the actual bot
require 'cinch'
require_relative 'monitore'
#create bot for IRC monitoring
bot = Cinch::Bot.new do
configure do |c|
c.server = "localhost"
c.channels = ["#cinch-bots"]
@ryanjones
ryanjones / restntlm
Created August 19, 2011 23:35
Adding ntlm to request.rb (rest-client)
require 'tempfile'
require 'mime/types'
require 'cgi'
require 'ntlm/http'
module RestClient
# This class is used internally by RestClient to send the request, but you can also
# call it directly if you'd like to use a method not supported by the
# main API. For example:
#
@ryanjones
ryanjones / fireget
Created August 19, 2011 23:36
code to test rest ntlm
require 'rest-client'
r = RestClient::Resource.new 'www.google.ca'
r.get
@ryanjones
ryanjones / restntlmerro
Created August 19, 2011 23:38
restntlm error
C:\Users\Owner>irb
irb(main):001:0> require 'rest-client'
=> true
irb(main):002:0> r = RestClient::Resource.new 'www.google.ca'
=> www.google.ca
irb(main):003:0> r.get
Net::HTTP::Get
NoMethodError: undefined method `ntlm_auth' for Net::HTTP::Get:Class
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rest-client-1.6.3/lib/restclien
t/request.rb:113:in `net_http_request_class'
@ryanjones
ryanjones / README.md
Created February 17, 2012 17:04 — forked from fnichol/README.md
Download a cacert.pem for RailsInstaller

Why?

There is a long standing issue in Ruby where the net/http library by default does not check the validity of an SSL certificate during a TLS handshake. Rather than deal with the underlying problem (a missing certificate authority, a self-signed certificate, etc.) one tends to see bad hacks everywhere. This can lead to problems down the road.

From what I can see the OpenSSL library that Rails Installer delivers has no certificate authorities defined. So, let's go fetch some from the curl website. And since this is for ruby, why don't we download and install the file with a ruby script?

Installation

The Ruby Way! (Fun)

@ryanjones
ryanjones / gparse.rb
Created June 10, 2012 18:53
Parse out the hrefs from a google search
require 'open-uri'
require 'nokogiri'
def google_results(keyword)
begin
results = []
doc = Nokogiri::HTML(open("https://www.google.com/search?q=#{keyword}"))
doc.xpath("//h3//a[@href]").each do |href|
@ryanjones
ryanjones / LICENSE
Created September 6, 2012 17:12 — forked from nathany/LICENSE
Pruning remote branches that are already in master
Copyright (C) 2012 Nathan Youngman
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
God.watch do |w|
w.name = 'remote_syslog'
w.interval = 7.seconds
w.log = File.join(RAILS_ROOT, 'log', "#{w.name}-god.log")
w.dir = RAILS_ROOT
w.start = "bundle exec remote_syslog --tls -D -c #{RAILS_ROOT}/config/remote_syslog.yml"
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@ryanjones
ryanjones / travis.yml
Created March 6, 2013 22:20
Create db/user for test db in travis yml
before_script:
- psql -c 'CREATE USER the_user WITH CREATEDB;' -U postgres
- psql -c 'CREATE database the_db_test;' -U postgres
- psql -c 'ALTER DATABASE the_db_test OWNER TO the_user' -U postgres