Skip to content

Instantly share code, notes, and snippets.

@christonog
christonog / testinfra.py
Created August 7, 2019 17:57
winrm support
def get_ansible_host(config, inventory, host, ssh_config=None,
ssh_identity_file=None):
if is_empty_inventory(inventory):
return testinfra.get_host('local://')
hostvars = inventory['_meta'].get('hostvars', {}).get(host, {})
connection = hostvars.get('ansible_connection', 'ssh')
if connection not in ('ssh', 'local', 'docker', 'lxc', 'lxd'):
wrote pytestdebug information to /roles/test-windows-config/molecule/windows/pytestdebug.log
raise NotImplementedError(
> 'unhandled ansible_connection {}'.format(connection))
@christonog
christonog / Sinatra_Rspec_helper_.rb
Created April 27, 2012 01:19
Code I can use to set up Rspec testing within my sinatra apps
# name this file spec_helper.rb, and put it in the spec directory (root_of_app/spec/[file])
require File.join(File.dirname(__FILE__), '..', 'my_sinatra_app.rb')
require 'sinatra'
require 'rack/test'
#setup test environment
set :environment, :test
puts "I want to pay x amount per month. How much house can I afford?"
each_payment = gets.chomp.to_i
interest_rate = 0.045
interest_rate_per_period = interest_rate/12
number_of_payments = 360
loan_amount = (each_payment/interest_rate_per_period)*(1-(1+interest_rate_per_period)**-number_of_payments)
puts loan_amount
@christonog
christonog / file_create.rb
Created November 16, 2011 03:15
Ruby file creation script
=begin
first edition: 11/15/2011
I created this script in order to help me create files with the same extension quickly. It's not too powerful, but gets
the job done and can be somewhat customized to suit the needs of the user (granted if they can code in ruby)
Hope it helps!
-Chris
@christonog
christonog / tracker.rb
Created November 12, 2010 15:10
script to collate the tracking of various shipping services
require 'rubygems'
require 'sinatra'
get '/' do
"enter the tracking number in the url:
ltracker.heroku.com/tracking/(your tracking number)"
end
get '/tracking/:number' do
# UPS code