Skip to content

Instantly share code, notes, and snippets.

View redperadot's full-sized avatar

Cody Hannafon redperadot

  • Ithaca NY
View GitHub Profile
@redperadot
redperadot / pong.rb
Last active August 29, 2015 14:09
Monitor network addresses.
#!/usr/bin/env ruby
#
# pong.rb v0.1.3 - Monitor network addresses.
# Made with ❤︎ by [email protected]
module Scripter extend self
def clean_exit(message = nil)
Signal.trap("INT") { |signo| Scripter.tput('clear'); puts; puts message if message; exit 0 }
end
@redperadot
redperadot / vtplayer.rb
Created July 31, 2014 19:51
A simple script to play vt100 animations.
#!/usr/bin/env ruby
#
# vtplayer.rb - A simple script to play vt100 animations.
# Made with ❤︎ by [email protected] - v0.1
#
# Some places to find vt100 animations:
# http://artscene.textfiles.com/vt100/
# http://www.scovetta.com/archives/textfiles/art
require 'open-uri'
@redperadot
redperadot / auto-ssh.rb
Last active August 29, 2015 14:01
Setup SSH login without a password.
#!/usr/bin/env ruby
#
# auto-ssh.rb - Setup SSH login without a password.
# Made with ❤︎ by [email protected]
## Gem Installer
def require_gems(*gems)
gems.each do |_gem|
begin require _gem
rescue LoadError
@redperadot
redperadot / grsp.rb
Created May 21, 2014 13:25
Get remote OS X system profile.
#!/usr/bin/env ruby
#
# grsp.rb - Get remote OS X system profile. Version 0.1
# Made with ❤︎ by [email protected]
require 'optparse'
require 'io/console'
require 'net/ssh'
Signal.trap("INT") { puts; exit 0 }
@redperadot
redperadot / as_user.rb
Created April 28, 2014 22:04
Run a block of code as another user in Ruby. You could use it to unsudo a sudoed script.
#!/usr/bin/env ruby
require 'etc'
def as_user(user = Etc.getlogin, &block)
u = (user.is_a? Integer) ? Etc.getpwuid(user) : Etc.getpwnam(user)
puts "Running child process as the user #{user}(#{u.uid})."
pid = Process.fork do
Process.uid = u.uid
block.call(user)
end
@redperadot
redperadot / uri.rb
Last active November 22, 2022 08:12
Encode and decode URI strings with Ruby.
#!/usr/bin/env ruby
require 'uri'
pb = ( (/darwin/ =~ RUBY_PLATFORM) != nil ? true : false )
## Get Options
if ARGV[0] == "-h"
puts "#{$0} -e [STRING] (Encode String)"
puts "#{$0} -d [STRING] (Decode String)"
exit 0
end
@redperadot
redperadot / uninstall_node.sh
Created March 21, 2014 17:29
Script to uninstall node.js on OS X.
#!/bin/bash
[[ $(uname) != "Darwin" ]] && echo "OS X Only" && exit 1
sudo -v
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom \
| while read i; do
sudo rm /usr/local/${i}
done
@redperadot
redperadot / raffle.rb
Last active August 29, 2015 13:57
Raffle off items with ruby.
#!/usr/bin/env ruby
#
# raffle.rb - Raffle off items with ruby. Version 0.2
# Made with ❤︎ by [email protected]
#
# To use cd into a directory with a 'tickets.txt'
# file and a 'items.txt' file. Then just run the
# script. Items in the files should be separated
# by new lines.
@redperadot
redperadot / mac_vendor.sh
Last active May 16, 2023 21:39
Get the vendor for a mac address from the terminal.
#!/usr/bin/env bash
#
# mac_vendor.sh - Get the vendor for a mac address from the terminal.
# Made with ❤︎ by [email protected]
# Set Functions
usage()
{
echo "MAC Vendor Help"
echo "mac_vendor -a 'MAC Address' | Get the vendor of the specified address."
@redperadot
redperadot / host_down.sh
Last active August 29, 2015 13:55
Do you ping constantly but only want to know when a host is down? Well this little script does just that.
#!/usr/bin/env bash
# [email protected]
# host_down.sh
[[ $1 == "-a" ]] && audible='\a' && shift || audible=
address_1=$1
address_2=$2
[[ -z $address_1 ]] && read -p "Address #1 to ping: " address_1
[[ -z $address_2 ]] && read -p "Address #2 to ping: " address_2