"Wicked Cool Ruby Scripts: Useful Scripts that Solve Difficult Problems" by Steve Pugh
Editor William Pollock
No Starch Press | 2009 | ISBN: 1593271824 9781593271824 | 437 pages | PDF/epub/mobi | 7/1 MB
Editor William Pollock
No Starch Press | 2009 | ISBN: 1593271824 9781593271824 | 437 pages | PDF/epub/mobi | 7/1 MB
This book is a compendium of scripts that will make your life easier by saving you time and solving problems. If you find yourself wasting effort and time on a task a trained monkey could do, it's time for Ruby to come to the rescue. This issue provides carefully selected Ruby scripts that are immediately useful.
Learn how to streamline administrative tasks like renaming files, disabling processes, and changing permissions. After you get your feet wet creating basic scripts, author Steve Pugh will show you how to create powerful Web crawlers, security scripts, full-fledged libraries and applications, and much more. With each script you'll get the raw code followed by an explanation of how it really works, as well as instructions for how to run the script and suggestions for customizing it.
Wicked Cool Ruby Scripts will save you from the tedium of repetitive tasks and give you back the time it would take to write scripts from scratch.
Organization and Approach
For each of the scripts, I'll walk you through the logic and usage, then through the underlying principles involved in writing the script. Finally, I'll put you in the driver's seat and suggest some ways you can hack the script to make it your own and more versatile. These scripts are not going to solve every need you have, but my hope is that they will help you think about how you can write your own scripts—learning through example. Feel free to download the scripts and use them however you want to.
Chapter 1: General Purpose Utilities
Ruby is an ideal language for creating small, everyday scripts. This chapter includes helpful utilities for simple tasks like encrypting and decrypting files, splitting and joining files, compressing and decompressing files, tracking file changes, viewing a complete list of running processes, and calculating your mortgage payments.
Chapter 2: Website Scripting
Ruby and the Web go together like a horse and carriage. If you're familiar with Ruby, then you have probably heard of Rails, the web framework that drives much of Ruby's adoption. This chapter contains scripts that make website administration, RSS parsing, and web form generation easier. You can also use the scripts in this chapter for quality assurance testing, since they'll test for broken hyperlinks and orphan files.
Chapter 3: Li(U)nix System Administration
Systems administration can be made much easier through the use of scripting, and Ruby is an ideal language for automating mundane system administration tasks. This chapter includes scripts for administering users as well as detecting and killing process hogs on your devices. Automation of system administration tasks is one of the major uses of scripting, and it's also an area with the most room for creativity.
Chapter 4: Picture Utilities
Digital photography has become the new way to capture and share memories, whether it's through the Web, email, or physical media. One problem I've run into, though, is that the amount of photographs I take becomes overwhelming. I can't do the things I used to enjoy, like organizing, touching-up, or sharing photos with people, because there are too many images, and I don't have enough time to go through them all. This chapter will show you ways to automate the tedious task of resizing, renaming, and organizing your digital photographs. I will also show you how to protect your creative works by watermarking your photos. For readers who like to analyze picture information, this chapter also demonstrates how to extract the information stored in the metadata.
Chapter 5: Games and Learning Tools
This chapter shows some simple games that can be developed using Ruby. Have you caught on to the Sudoku craze? The Sudoku solver will solve a puzzle in less time than it will take for you to enter the numbers. What about an interactive Rock, Paper, Scissors opponent? I will show you several other entertaining scripts and explain them so you can make your own games and entertain your friends.
Chapter 6: String Utilities
Ruby's text manipulation and processing utilities are powerful. This chapter will dive into parsing comma-separated value (CSV) files, generating and manipulating documents, and searching for a specific string within documents.
Chapter 7: Servers and Scrapers
There is a lot of information floating around the ether of the Internet. This chapter shows you ways to extract that information and put it into easy-to-use formats. For example, you can grab all the pictures off of a website and save them to a specified folder with a specific naming convention. You'll learn how to automate your web browser to navigate websites, complete forms, and otherwise act like a typical user. And I'll show you how to automatically send SMS messages to your friends using a Ruby script.
Chapter 8: Arguments and Documentation
After reading through this book, you'll have a good understanding of using Ruby in the wild. This chapter will show you how to polish and put the finishing touches on your wicked cool scripts. You'll be able to write your own professional scripts in no time!
Chapter 9: Sorting Algorithms
This chapter is a collection of sorting algorithms that are popular in academia and are otherwise nice to know about. The algorithms are analyzed and tested using the Unit:Test library to show differences in performance and efficiency. Since any given problem has a myriad of solutions, having multiple options available will increase your chances of choosing the most fitting answer. You can use the Unit:Test library to discover which methods are the most efficient and effective.
Chapter 10: Writing a Metasploit 3.1 Module with Ruby
Computer security is a rapidly growing field, and Metasploit is one tool available for security research. This chapter combines two of my favorite subjects and shows you how to write an exploit using Ruby and Metasploit. We will walk through how to write a custom exploit, step by step.
Table of Contents
FOREWORD
ACKNOWLEDGMENTS
INTRODUCTION
Wicked Cool Ruby Scripts
You Need Ruby Basics
Documentation
Organization and Approach
The Website
1. GENERAL PURPOSE UTILITIES
2. WEBSITE SCRIPTING
3. LI(U)NIX SYSTEM ADMINISTRATION
4. PICTURE UTILITIES
5. GAMES AND LEARNING TOOLS
6. STRING UTILITIES
7. SERVERS AND SCRAPERS
8. ARGUMENTS AND DOCUMENTATION
9. SORTING ALGORITHMS
10. WRITING A METASPLOIT 3.1 MODULE WITH RUBY
A. AFTERWORD
with TOC BookMarkLinks