Skip to content

Instantly share code, notes, and snippets.

View ryanjones's full-sized avatar

Ryan Jones ryanjones

View GitHub Profile
@ryanjones
ryanjones / html_heroku
Last active August 29, 2015 13:57
Quick html site on heroku w/ rack
## run manually, currently not worth scripting.
## from https://devcenter.heroku.com/articles/static-sites-ruby
mkdir appname
mkdir -p site/public/{images,js,css}
touch site/{config.ru,public/index.html}
cd site && bundle init
echo -e "source :rubygems\ngem 'rack'" > Gemfile
# Description:
# Automates aspects of mover.io's current Github workflow which leverages
# Github's issue tags and commenting system. We previously used a :+1:
# comment to approve pull requests, but doing so did not affect the state of
# the the PR.
#
# Included is a Github webhook handler that checks for comments containing
# certain trigger words. Currently:
#
# :+1: The pull request is approved.
@ryanjones
ryanjones / items_controller.rb
Last active August 29, 2015 14:10
Leverage decent exposure
# controller w/ decent exposure
class ItemsController < ApplicationController
expose(:item)
expose(:items)
def create
if item.save
redirect_to(item)
else
$(function () {
$('[data-toggle="tooltip"]').tooltip();
$('#membership-form').on('submit', function(e){
var member = $( "input:first" ).val();
e.preventDefault();
$.ajax({
method: "GET",
url: "https://api.ama.ab.ca/reward_dollars/promotions/3/contestants/"+ member +".jsonp",
jsonp: "callback",
@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 / 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 / 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 / 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