Skip to content

Instantly share code, notes, and snippets.

View jjam3774's full-sized avatar

Jeffrey James jjam3774

View GitHub Profile
#!/usr/bin/ruby
require 'optparse'
options = {:username => nil, :role => nil, :group => nil}
parser = OptionParser.new do|opts|
opts.banner = "Usage: bl-rest.rb [options]"
opts.on('-u', '--username name', 'username') do |username|
options[:username] = username;
@jjam3774
jjam3774 / pty_demo.rb
Last active July 29, 2020 23:03
Demonstration of PTY for Automating Interactive Applications
#!/usr/bin/ruby
require 'expect'
require 'pty'
# PTY without expect can easily automate interactive programs...
PTY.spawn('./inter.rb'){|o,i,p|
i.puts("yes")
o.gets #not needed to work just included it to clean up look on-screen
i.puts("yes")
@jjam3774
jjam3774 / IO.popen_example.rb
Last active August 29, 2015 14:03
Using Zenity with Ruby to show the use of the progress bar
#!/usr/bin/ruby
def service_agent
e = IO.popen('zenity --height=250 \
--list \
--checklist \
--column "restart" \
--column "service" \
@jjam3774
jjam3774 / replace_string.rb
Last active July 29, 2020 23:04
This will replace strings in a file.
#!/usr/bin/ruby -w
def replace_ref(file, fileindx, &directive)
old_stdout = $stdout
argf = ARGF.clone
argf.argv.replace [file]
argf.inplace_mode = fileindx
argf.each_line() { |line|
yield line
@jjam3774
jjam3774 / changestring.rb
Last active July 29, 2020 23:04
Changing files and creating a backup of file....
#!/usr/bin/ruby -w
def replace_ref(file, fileindx, &directive)
old_stdout = $stdout
argf = ARGF.clone
argf.argv.replace [file]
argf.inplace_mode = fileindx
argf.each_line() { |line|
yield line
@jjam3774
jjam3774 / pycurlexample.py
Last active July 29, 2020 23:06
Example of using PyCurl.....
#!/usr/bin/python
import urllib2
import json
import getpass
import sys
def rest_uptime(password):
username = raw_input("Username: ")
@jjam3774
jjam3774 / httpdagent.py
Last active July 29, 2020 23:11
Url Agent to monitor domain
#!/usr/bin/python
import urllib2
import mechanize
import socket
import os
import platform
class HttpdAgent():
def __init__(self):
@jjam3774
jjam3774 / cookiemonster.py
Last active July 29, 2020 23:09
Update Version Jason Orana and Jeffrey James script
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
A utility that will decode, encode F5 Cookie info
Perform dns lookups
Reverse dns lookups
Pull port,instance and hostname info
Refer to:
http://support.f5.com/kb/en-us/solutions/public/6000/900/sol6917.html
'''
@jjam3774
jjam3774 / track_page_load.py
Last active November 16, 2018 20:15
Tracks the time for a page to load
#!/usr/bin/python
# -*- coding: utf-8 -*-
import urllib2
import os
import time
def complete_info():
error_file = open('error_file.txt', 'w')
for i in open('linkfile'):
@jjam3774
jjam3774 / loadakamai.py
Created February 17, 2014 17:27
load with akamai
#!/usr/bin/python
# -*- coding: utf-8 -*-
# <nbformat>3.0</nbformat>
# <codecell>
from httplib import HTTPConnection
import time
import re