Skip to content

Instantly share code, notes, and snippets.

View cowboy-cod3r's full-sized avatar

Sean Humbarger cowboy-cod3r

  • The Walt Disney Company
  • Colorado Springs
  • 10:19 (UTC -06:00)
View GitHub Profile
@cowboy-cod3r
cowboy-cod3r / fork.rb
Created November 22, 2013 03:07
Ruby: Fork
# Fork a Process
pid = fork do
# Do stuff
# Do more stuff
end
# Wait for the process to complete before moving on
Process.wait
@cowboy-cod3r
cowboy-cod3r / class_template.rb
Created November 22, 2013 03:49
Ruby Class Template
class MyPackage
# == Description
# A Description of the class
class MyClass
# Accessors
attr_accessor :attr1, :attr2
# ==== Description
@cowboy-cod3r
cowboy-cod3r / linux-memory
Created November 23, 2013 18:35
Linux: Memory
[sean.humbarger@ISS203943 ~]$ free -m
total used free shared buffers cached
Mem: 16006 1434 14572 0 50 575
-/+ buffers/cache: 808 15197
Swap: 7871 0 7871
# =========================================================================
'Mem' Row 'total' Column
* This is the total amount of RAM installed on your machine. It is the sum of the 'used' and free columns on the same row
@cowboy-cod3r
cowboy-cod3r / uninstall-gems.sh
Created November 25, 2013 17:01
Ruby: Uninstall a List of Gems
# Get a list of gems
for i in $(/opt/apps/ruby/ruby/bin/gem list --no-versions);
do
# If list the gem starts with 'ivv'
if [[ "$i" == ivv* ]];then
# Uninstall the gem
# -x : removes executables
# -I : ignores dependencies
# -a : removes all versions
@cowboy-cod3r
cowboy-cod3r / metaprogramming.rb
Created November 27, 2013 20:59
Ruby: Metaprogramming
# Get the class type
my_obj.class
# get the instance methods of a class
# false indicates that inherited method should not be included
my_obj.class.instance_methods(false)
# get instance variables
# In ruby, instance variables aren't tied to a class like in java.
# They only spring into existence when they are assigned.
@cowboy-cod3r
cowboy-cod3r / gem_location.rb
Created December 2, 2013 21:10
Ruby: Gem Utilities
# Determine the location of a gem that has been installed
spec = Gem::Specification.find_by_name("cucumber")
gem_root = spec.gem_dir
gem_lib = File.join(gem_root, "lib")
@cowboy-cod3r
cowboy-cod3r / jvisualvm
Created December 7, 2013 03:19
Java: Steps for JVisualVM
1. On the tomcat server, do the following:
a. Open the firefwall to allow connections over the jmx port
b. Make the following directories
mkdir -p /home/tomcat/.jvisualvm/7u6
chown -R tomcat:tomcat /home/tomcat
c. Add the following java options to tomcat in setenv.sh
-Dcom.sun.management.jmxremote
@cowboy-cod3r
cowboy-cod3r / dates.sh
Created December 7, 2013 17:38
Bash: Dates
# Get today's date/time
date
# Get today's date only
date +%d-%b-%Y
@cowboy-cod3r
cowboy-cod3r / bash_files_folders.sh
Created December 7, 2013 18:05
Bash: File/Folder Functions
# Get the current file
current_file = $0
# Get the full path to the current file
full_file_path="$(readlink -f $(dirname $0))/$(basename $0)"
# Get the full directory path to the current file
full_dir_path="$(readlink -f $(dirname $0))"
@cowboy-cod3r
cowboy-cod3r / bash_root.sh
Created December 7, 2013 18:08
Bash: Root User?
if [[ $EUID -ne 0 ]]; then
echo "ERROR: The user must be root in order to execute this script."
exit 1
fi