The Ruby Cookbook Official Unofficial Homepage

Jolt Awards nominee!

"Programmers don't live by language syntax alone, but by every line of concrete code they write. To that end, this book is filled with practical recipes, tips, knowledge, and wisdom. I hope it leads readers to the next step of Ruby programming."
--Matz
You think they're the traditionally mundane recipes, but nope, it's all slathered in hollandaise. Oh, man, the examples: adhoc versioning systems, bittorrent clients and ads for your lost dinosaur. The protocols chapter is just good fun. Sticky, sweet nectar will be running off your face! Yes, and some sizeable bacon.
--why
"I've lost count of the times I've googled for ages for some ruby trick and found it in the Cookbook in about 10 seconds."
--Ashley Moran

More raves for the Ruby Cookbook!

Hello, this is Leonard Richardson, and you're about to experience the Ruby Cookbook. (Get it from O'Reilly, Amazon, B&N, or Powell's).

The work of myself, Lucas Carlson, and about twenty contributors, this book covers all aspects of Ruby (see the outline below). We devote ten chapters to general topics like data structures, algorithms, and metaprogramming. We devote five to network applications and closely related topics, including chapters on Rails, databases, and XML/HTML. We cover the tools that Ruby provides to improve your programs: unit tests, performance analysis, Rake, and Rubygems. We also cover thread and process management, C extensions, GUI and console applications.

We hope people will find this book a better reference than O'Reilly's Perl and Python Cookbooks. It contains about 100 more recipes than a typical first edition Cookbook.

Source Code

I've made available a zip file containing all the code in the Ruby Cookbook, one file per recipe.

The Outline

This is the official outline for the book. Each recipe and chapter intro is given a "confidence score" and color-coded. The confidence scores are meaningless in any absolute sense, but you can compare them to each other to see which recipes got the most coverage.

A word about the tests: we have a script that parses the recipes, runs the code samples in an instrumented irb session, and compares the results against what it says in the book. The script can't replace a human looking at the results (a test might "fail" because it involves something like current time, and some recipes can't be automatically tested at all), but it makes it a lot easier to see if there are problems with the code.
RecipeScoreEyesCommentsRevisionsTestsWiki ID
0. Preface 0.70 0 3 0 3/3 78801
1. Strings (Introduction) 1.40 2 4 1 23/23 7732
1. Building a String From Parts 1.10 3 2 1 5/5 13785
2. Substituting Variables Into Strings 0.90 3 1 1 12/12 7829
3. Substituting Variables Into an Existing String 0.89 1 2 1 12/13 23230
4. Reversing a String by Words or Characters 1.30 3 3 1 8/8 7802
5. Representing Unprintable Characters 0.76 2 1 1 20/31 7841
6. Converting Between Characters and Values 0.80 2 1 1 10/10 7823
7. Converting Between Strings and Symbols 0.75 2 1 1 6/12 7862
8. Processing a String One Character at a Time 1.35 2 4 1 3/6 7805
9. Processing a String One Word at a Time 0.84 3 1 1 3/8 73477
10. Changing the Case of a String 0.90 3 1 1 13/13 7808
11. Managing Whitespace 0.90 3 1 1 11/11 7811
12. Testing Whether an Object Is String-like 1.00 2 2 1 6/6 7814
13. Getting the Parts of a String You Want 0.90 3 1 1 15/15 7826
14. Handling International Encodings 0.90 3 1 1 6/6 7832
15. Word-wrapping Lines of Text 0.90 3 1 1 6/6 7871
16. Generating a Succession of Strings 0.90 3 1 1 26/26 7856
17. Comparing With Regular Expressions 0.90 3 1 1 11/11 7859
18. Replacing Multiple Patterns in a Single Pass 0.80 2 1 1 6/6 7853
19. Validating an Email Address 0.80 2 1 1 13/13 7877
20. Classifying Text with a Bayesian Analyzer 0.77 2 1 1 5/7 80117
2. Numbers (Introduction) 0.60 2 0 1 11/11 7735
1. Parsing A Number From A String 0.70 1 1 1 33/33 9858
2. Comparing Floating-Point Numbers 0.70 1 1 1 14/14 10048
3. Representing Numbers to Arbitrary Precision 0.60 2 0 1 33/33 11433
4. Representing Rational Numbers 0.70 1 1 1 16/16 11483
5. Generating Random Numbers 0.60 2 0 1 19/19 8530
6. Converting Between Numeric Bases 0.80 2 1 1 18/18 14020
7. Taking Logarithms 0.60 2 0 1 15/15 11137
8. Taking Mean, Median, and Mode 0.60 2 0 1 26/26 11604
9. Converting Between Degrees and Radians 0.60 2 0 1 19/19 18312
10. Multiplying Matrices 0.55 2 0 1 4/8 14511
11. Solving a System of Linear Equations 0.51 2 0 1 1/8 14711
12. Using Complex Numbers 0.59 2 0 1 11/12 18100
13. Simulating a Subclass of Fixnum 0.69 1 1 1 23/25 14665
14. Doing Math with Roman Numbers 0.70 1 1 1 21/21 17000
15. Generating a Sequence of Numbers 0.60 2 0 1 8/8 9846
16. Generating Prime Numbers 0.60 2 0 1 13/13 9839
17. Checking a Credit Card Checksum 0.59 2 0 1 7/8 18213
3. Date and Time (Introduction) 0.78 2 1 1 16/20 7738
1. Finding Today's Date 0.66 1 1 1 22/34 11681
2. Parsing Dates Fuzzily or Precisely 0.59 2 0 1 32/34 10313
3. Printing a Date 0.68 1 1 1 11/13 19146
4. Iterating Over Dates 0.70 1 1 1 6/6 10630
5. Doing Date Arithmetic 0.69 1 1 1 27/31 19134
6. Counting the Days Since an Arbitrary Date 0.65 1 1 1 4/8 19222
7. Converting Between Time Zones 0.56 2 0 1 11/19 14228
8. Checking Whether Daylight Saving Time Is Currently in Effect 0.69 1 1 1 18/19 14143
9. Converting Between Time and DateTime Objects 0.58 2 0 1 17/20 19041
10. Finding the Day of the Week 0.67 1 1 1 4/6 19163
11. Handling Commercial Dates 0.40 1 1 0 8/8 83650
12. Running a Code Block Periodically 0.50 2 0 1 n/a 19237
13. Waiting a Certain Amount of Time 0.62 1 1 1 2/9 14241
14. Adding a Timeout to a Long-Running Operation 0.30 1 1 0 0/3 83594
4. Arrays (Introduction) 0.50 1 0 1 24/24 7741
1. Iterating Over an Array 0.69 1 1 1 13/14 11698
2. Exchanging Values Without Using Temporary Variables 1.00 2 2 1 22/22 7838
3. Stripping Duplicate Elements from an Array 0.70 1 1 1 7/7 10037
4. Reversing an Array 0.60 2 0 1 3/3 8653
5. Shuffling an Array 0.63 1 1 1 1/3 8634
6. Ignoring Case When Sorting Strings 0.67 1 1 1 2/3 10415
7. Sorting an Array by an Attribute of its Objects 0.70 1 1 1 6/6 11638
8. Making Sure a Sorted Array Stays Sorted 0.59 2 0 1 20/23 13670
9. Summing Each Item of an Array 0.50 1 0 1 3/3 9008
10. Sorting an Array by Frequency of Appearance 0.70 1 1 1 13/13 11725
11. Getting the n Smallest Items of an Array 0.47 1 0 1 8/11 13804
12. Building Up a Hash Using Injection 0.70 1 1 1 6/6 9001
13. Extracting Portions of Arrays, Destructively and Non- 0.80 0 2 1 45/45 13997
14. Treating an Array as a Queue 0.50 1 0 1 12/12 8641
15. Computing Set Operations on Arrays 0.48 1 0 1 13/16 8575
16. Partitioning or Classifying a Set 0.43 1 0 1 4/12 13903
5. Hashes (Introduction) 0.60 2 0 1 13/13 7751
1. Using Symbols as Hash Keys (written by Ben Giddings) 0.67 1 1 1 6/9 19540
2. Creating a Hash with a Default Value (written by Ben Giddings) 0.58 2 0 1 10/12 19489
3. Adding Elements to a Hash 0.60 2 0 1 16/16 8583
4. Removing Elements from a Hash 0.60 2 0 1 11/11 8565
5. Using an Array or Other Modifiable Object as a Hash Key 0.58 2 0 1 8/10 11049
6. Keeping Multiple Values for the Same Hash Key 0.70 1 1 1 2/2 11714
7. Iterating Over a Hash 0.79 0 2 1 12/13 8514
8. Iterating Over a Hash in Insertion Order 0.60 2 0 1 3/3 18159
9. Printing a Hash (written by Ben Giddings) 0.56 2 0 1 6/10 19529
10. Inverting a Hash 0.68 1 1 1 3/4 8523
11. Choosing Randomly From a Weighted List 0.56 2 0 1 3/5 18800
12. Building a Histogram 0.70 1 1 1 6/6 14271
13. Making a Hash More Like a Struct 0.70 1 1 1 9/9 8627
14. Remapping the Keys and Values of A Hash 0.65 1 1 1 1/2 12147
15. Extracting Portions of Hashes (written by Ben Giddings) 0.50 2 0 1 0/4 19517
16. Searching a Hash with Regular Expressions 0.70 1 1 1 6/6 10700
6. Files and Directories (Introduction) 0.54 2 0 1 2/5 7754
1. Checking to See if a File Exists 0.70 1 1 1 12/12 8594
2. Checking Your Access to a File 0.68 1 1 1 10/12 10082
3. Changing the Permissions on a File 0.59 2 0 1 11/12 20180
4. Checking When a File was Last Used 0.53 2 0 1 2/8 20407
5. Listing A Directory 0.50 2 0 1 0/18 10307
6. Reading the Contents of a File 0.76 2 1 1 12/21 10621
7. Writing to a File 0.57 2 0 1 3/4 19746
8. Writing to a Temporary File 0.53 2 0 1 1/3 20378
9. Picking a Random Line from a File 0.70 1 1 1 4/4 10088
10. Comparing the Contents of Two Files 0.68 1 1 1 5/6 18149
11. Performing Random Access on "Read-Once" Input Streams 0.60 2 0 1 11/11 20396
12. Walking a Directory Tree 0.60 1 1 1 0/5 17044
13. Locking a File 0.70 1 1 1 3/3 20367
14. Backing Up to Versioned Filenames 0.70 1 1 1 10/10 18125
15. Pretending a String is a File 0.59 2 0 1 16/17 10320
16. Redirecting Standard Input or Output 0.50 2 0 1 n/a 20696
17. Processing a Binary File 0.88 1 2 1 18/22 20192
18. Deleting a File 0.60 2 0 1 5/5 18430
19. Truncating a File 0.60 2 0 1 11/11 17214
20. Finding the Files you Want 0.50 2 0 1 0/10 19760
21. Finding and Changing the Current Working Directory 0.57 2 0 1 2/3 10637
7. Code Blocks and Iteration (Introduction) 0.79 2 1 1 15/16 7757
1. Invoking Blocks 0.80 2 1 1 8/8 9797
2. Writing a Method that Accepts a Block 0.80 2 1 1 10/10 9794
3. Binding a Block Argument to a Variable 0.60 2 0 1 8/8 17034
4. Blocks as Closures: Using Outside Variables Within a Code Block 0.80 2 1 1 6/6 23113
5. Writing an Iterator Over a Data Structure 0.80 2 1 1 4/4 9800
6. Changing the Way an Object Iterates 0.18 1 0 0 7/9 9815
7. Writing Block Methods that Classify or Collect 0.70 3 0 1 1/1 9812
8. Stopping an Iteration 0.77 2 1 1 3/4 9803
9. Looping Through Multiple Iterables in Parallel 0.80 2 1 1 14/14 9806
10. Hiding Setup and Cleanup in a Block Method 0.80 1 2 1 0/2 9809
11. Coupling Systems Loosely with Callbacks 0.75 2 1 1 2/4 9818
8. Object-Oriented Programming (Introduction) 0.84 1 2 1 4/10 7760
1. Managing Instance Data 0.47 1 0 1 8/12 24045
2. Managing Class Data 0.50 1 0 1 8/8 25248
3. Checking Class or Module Membership 0.50 1 0 1 9/9 23965
4. Writing an Inherited Class 0.69 1 1 1 6/7 25310
5. Overloading Methods 0.43 1 0 1 1/3 25632
6. Validating and Modifying Attribute Values 0.60 0 1 1 9/9 18202
7. Defining a Virtual Attribute 0.50 1 0 1 2/2 26905
8. Delegating Method Calls to Another Object 0.48 1 0 1 11/13 16972
9. Converting and Coercing Objects to Different Types 0.39 1 1 0 22/24 18773
10. Getting a Human-Readable Printout of Any Object 0.68 1 1 1 12/15 10241
11. Accepting or Passing a Variable Number of Arguments 0.70 1 1 1 9/9 14399
12. Simulating Keyword Arguments 0.67 1 1 1 7/10 10063
13. Calling a Superclass's Method 0.60 2 0 1 5/5 10686
14. Creating an Abstract Method 0.70 1 1 1 7/7 10216
15. Freezing an Object to Prevent Changes 0.79 2 1 1 11/12 12468
16. Making a Copy of an Object 1.00 1 1 2 14/14 18419
17. Declaring Constants 0.57 0 1 1 12/16 7847
18. Implementing Class and Singleton Methods 0.50 1 0 1 10/10 10327
19. Controlling Access by Making Methods Private 0.48 1 0 1 9/11 18185
9. Modules and Namespaces (Introduction) 0.30 2 0 0 3/3 26971
1. Simulating Multiple Inheritance with Mixins 0.85 0 1 2 2/4 16982
2. Extending Specific Objects with Modules (written by Phil Tomson) 0.90 2 0 2 8/8 82123
3. Mixing in Class Methods (written by Phil Tomson) 1.00 1 1 2 2/2 32600
4. Implementing Enumerable: Write One Method, Get 22 Free 0.47 1 0 1 8/11 83616
5. Avoiding Naming Collisions with Namespaces 0.50 1 0 1 3/3 26893
6. Automatically Loading Files as Needed 0.44 1 0 1 3/7 25619
7. Including Namespaces 0.60 1 1 1 0/1 26977
8. Initializing Instance Variables Defined by a Module (written by Phil Tomson) 0.35 3 0 0 1/2 73160
9. Automatically Initializing Mixed-In Modules (written by Phil Tomson) 0.20 2 0 0 n/a 74430
10. Reflection and Metaprogramming (Introduction) 0.40 1 0 1 0/0 7763
1. Finding the Class and Superclass of an Object 0.90 3 1 1 15/15 18783
2. Listing an Object's Methods 0.78 0 2 1 10/13 11648
3. Listing Methods Unique to an Object 0.80 0 2 1 12/12 11671
4. Getting a Reference to a Method 0.50 1 0 1 12/12 10644
5. Fixing Bugs in Someone else's Class 0.50 1 0 1 3/3 23662
6. Listening for Changes to a Class (written by Phil Tomson) 0.60 0 1 1 3/3 31970
7. Checking Whether an Object Has Necessary Attributes 0.50 1 0 1 1/1 23983
8. Responding to Calls to Undefined Methods 0.58 0 1 1 22/26 17261
9. Automatically Initializing Instance Variables 0.50 1 0 1 2/2 26902
10. Avoiding Boilerplate Code with Metaprogramming 0.47 1 0 1 5/7 26932
11. Metaprogramming with String Evaluations 0.60 0 1 1 7/7 31983
12. Evaluating Code in an Earlier Context 0.50 1 0 1 3/3 26929
13. Undefining a Method 0.50 1 0 1 19/19 14528
14. Aliasing Methods 0.60 2 0 1 14/14 14651
15. Doing Aspect-Oriented Programming 0.18 1 0 0 4/5 77546
16. Enforcing Software Contracts (written by Maurice Codik) 0.32 1 1 0 1/5 18584
11. XML and HTML (Introduction) 0.40 1 0 1 0/0 7766
1. Checking XML Well-Formedness (written by Rod Gaither) 0.48 1 0 1 3/4 23574
2. Extracting Data From a Document's Tree Structure (written by Rod Gaither) 0.60 2 0 1 4/4 78473
3. Extracting Data While Parsing a Document (written by Rod Gaither) 0.60 2 0 1 1/1 78480
4. Navigating a Document with XPath 0.60 2 0 1 13/13 74576
5. Parsing Invalid Markup 0.68 1 1 1 7/9 74353
6. Converting an XML Document into a Hash 0.53 2 0 1 2/8 75831
7. Validating an XML Document (written by Mauro Cicio) 0.70 1 1 1 2/2 78946
8. Substituting XML Entities 0.58 2 0 1 9/11 78399
9. Creating and Modifying XML Documents 0.65 1 1 1 8/15 75942
10. Compressing Whitespace in an XML Document 0.60 2 0 1 5/5 74363
11. Guessing a Document's Encoding (written by Mauro Cicio) 0.60 2 0 1 2/2 79067
12. Converting From One Encoding to Another (written by Mauro Cicio) 0.60 2 0 1 2/2 79231
13. Extracting All the URLs from an HTML Document 0.62 1 1 1 1/5 74345
14. Transforming Plain Text into HTML 0.80 1 2 1 0/1 78979
15. Converting HTML Documents From the Web into Text 0.50 2 0 1 0/3 7744
16. A Simple Feed Aggregator (written by Rod Gaither) 0.50 2 0 1 0/3 80103
12. Graphics and Other File Formats (Introduction) 0.40 1 0 1 0/0 80063
1. Thumbnailing Images (written by Antonio Cangiano) 0.55 0 1 1 4/8 32185
2. Adding Text to an Image (written by Antonio Cangiano) 0.50 0 1 1 0/1 33805
3. Converting Among Image Formats (written by Antonio Cangiano) 0.60 0 1 1 9/9 33360
4. Graphing Data 0.40 1 0 1 0/1 36408
5. Adding Graphical Context with Sparklines 0.53 0 1 1 1/4 36196
6. Strongly Encrypting Data 0.13 1 0 0 2/6 78938
7. Parsing Comma-Separated Data 1.10 1 3 1 8/8 7844
8. Parsing Not-Quite-Comma-Separated Data 0.80 0 2 1 7/7 11768
9. Parsing and Generating Excel Spreadsheets 0.30 0 1 0 4/4 80066
10. Compressing and Archiving Files with Gzip and Tar 0.57 0 1 1 5/7 20716
11. Reading and Writing Zip Files 0.55 0 1 1 1/2 20815
12. Reading and Writing Configuration Files 0.42 1 0 1 1/5 73167
13. Generating PDF Files 0.55 0 1 1 1/2 78955
14. Generating MIDI Music 0.52 0 1 1 1/5 78836
13. Databases and Persistence (Introduction) 0.80 1 2 1 0/1 7775
1. Serializing Data With YAML 0.53 0 1 1 5/15 37099
2. Serializing Data With Marshal 0.50 1 0 1 7/7 23581
3. Persisting Objects With Madeleine 0.20 0 1 0 n/a 73435
4. Indexing Unstructured Text with SimpleSearch 0.50 1 0 1 2/2 78555
5. Indexing Structured Text With Ferret 0.43 1 0 1 2/6 78544
6. Using Berkeley DB Databases 0.46 1 0 1 4/7 77140
7. Controlling MySQL on Unix 0.50 1 0 1 1/1 74310
8. Counting the Rows Returned by a Query 0.50 1 0 1 5/5 76356
9. Talking Directly to a MySQL Database 0.47 1 0 1 2/3 77152
10. Talking Directly to a Postgres Database 0.97 0 3 1 2/3 77383
11. Using Object Relational Mapping with ActiveRecord 0.55 0 1 1 4/8 78742
12. Using Object Relational Mapping with Og (written by Mauro Cicio) 0.54 0 1 1 4/10 81153
13. Building Queries Programmatically 0.23 0 1 0 1/4 81769
14. Validating Data with ActiveRecord 0.59 0 1 1 7/8 81534
15. Preventing SQL Injection Attacks 0.50 1 0 1 3/3 76986
16. Using Transactions in ActiveRecord 0.53 0 1 1 1/4 80719
17. Adding Hooks to Table Events 0.45 1 0 1 2/4 81551
18. Adding Taggability with a Database Mixin 0.20 0 1 0 0/1 81156
14. Internet Services (Introduction) 0.70 0 2 1 0/0 7772
1. Grabbing the Contents of a Web Page 0.77 0 2 1 8/11 11042
2. Making an HTTPS Web Request 0.78 0 2 1 4/5 18282
3. Customizing HTTP Request Headers 0.44 0 2 0 3/7 12823
4. Performing DNS Queries 0.48 0 2 0 3/4 17960
5. Sending Mail 0.65 1 1 1 2/4 32063
6. Reading Mail with IMAP (written by John Wells) 0.43 0 2 0 1/4 77062
7. Reading Mail with POP3 (written by John Wells) 0.30 1 1 0 0/2 79256
8. Being an FTP Client 0.65 1 1 1 1/2 34669
9. Being an Telnet Client 0.60 1 1 1 n/a 34594
10. Being an SSH Client 0.70 0 2 1 n/a 33098
11. Copying a File to Another Machine 0.70 0 2 1 n/a 37235
12. Being a BitTorrent Client 0.60 1 1 1 n/a 77676
13. Pinging a Machine 0.78 0 2 1 8/10 32052
14. Writing an Internet Server 0.90 0 3 1 n/a 74519
15. Parsing URLs 0.80 0 2 1 17/17 12549
16. Writing A CGI Script (written by Chetan Patil) 0.70 0 2 1 n/a 77593
17. Setting Cookies and Other HTTP Response Headers (written by Mauro Cicio) 0.60 1 1 1 n/a 81211
18. Uploading a File via CGI (written by Chetan Patil) 0.40 0 2 0 n/a 73415
19. Running Servlets with Webrick (written by John-Mason Shackelford) 0.20 0 1 0 n/a 82314
20. A Real-World HTTP Client 0.43 0 2 0 1/3 82397
15. Web Development: Ruby on Rails (Introduction) 0.00 0 0 0 0/0 7784
1. Writing a Simple Rails Application to Show System Status 0.70 0 2 1 n/a 14552
2. Passing Data From the Controller to the View 0.70 0 2 1 n/a 14561
3. Creating a Layout for Your Header and Footer 0.70 0 2 1 n/a 14558
4. Redirecting to a Different Location 0.70 0 2 1 n/a 14564
5. Displaying Templates with render 0.70 0 2 1 n/a 17056
6. Integrating a Database with Your Rails Application 0.70 0 2 1 n/a 14567
7. Understanding Pluralization Rules 0.80 0 2 1 9/9 14555
8. Creating a Login System 0.70 0 2 1 n/a 14570
9. Storing Hashed User Passwords in the Database 0.70 0 2 1 n/a 14580
10. Escaping HTML and Javascript for Display 0.70 0 2 1 n/a 14583
11. Setting and Retrieving Session Information 0.70 0 2 1 n/a 14586
12. Setting and Retrieving Cookies 0.70 0 2 1 n/a 14589
13. Refactoring Code Into Helper Functions 0.70 0 2 1 n/a 14592
14. Refactoring the View Into Partial Snippets of Views 0.70 0 2 1 n/a 14595
15. Adding DHTML Effects with script.aculo.us 0.70 0 2 1 n/a 14598
16. Generating Forms For Manipulating Model Objects 0.70 0 2 1 n/a 14601
17. Creating an AJAX Form 0.70 0 2 1 n/a 14604
18. Exposing Web Services on Your Website 0.70 0 2 1 n/a 14607
19. Sending Mail With Rails 0.70 0 2 1 n/a 14610
20. Automatically Sending Application Errors to Your Email 0.70 0 2 1 n/a 14613
21. Documenting Your Website 0.70 0 2 1 n/a 14616
22. Unit Testing your Website 0.70 0 2 1 n/a 14619
23. Using breakpoint in Your Web Application 0.70 0 2 1 n/a 14622
16. Web Services and Distributed Programming (Introduction) 0.20 0 1 0 0/0 7790
1. Searching For Books on Amazon.com 0.55 0 1 1 1/2 78529
2. Finding Photos on Flikr 0.50 0 1 1 0/2 79128
3. Writing an XML-RPC Client (written by John-Mason Shackelford) 0.80 0 2 1 5/5 77219
4. Writing a SOAP Client (written by Kevin Marshall) 0.70 0 2 1 0/2 76151
5. Writing a SOAP Server (written by Kevin Marshall) 0.70 0 2 1 n/a 77585
6. Searching the Web with Google's SOAP Service 0.50 0 1 1 n/a 78697
7. Using a WSDL File to Make SOAP Calls Easier (written by Kevin Marshall) 0.51 0 1 1 1/7 76365
8. Charging a Credit Card 0.50 0 1 1 0/2 78716
9. Finding the Cost to Ship Packages Via UPS or FedEx 0.53 0 1 1 1/4 78724
10. Sharing a Hash Between Any Number of Computers (written by James Edward Gray II) 0.20 0 1 0 n/a 19622
11. Implementing a Distributed Queue (written by James Edward Gray II) 0.20 0 1 0 n/a 19782
12. Creating a Shared "Whiteboard" (written by James Edward Gray II) 0.20 0 1 0 n/a 19570
13. Securing DRb Services with Access Control Lists (written by James Edward Gray II) 0.20 0 1 0 n/a 20148
14. Automatically Discovering DRb Servers and Clients (written by James Edward Gray II) 0.20 0 1 0 n/a 20205
15. Proxying Objects that Can't Be Distributed (written by James Edward Gray II) 0.20 0 1 0 n/a 23266
16. Storing Data on Distributed RAM (written by Ben Bleything with Michael Granger) 0.20 0 1 0 n/a 78989
17. Caching Expensive Results with memcached (written by Michael Granger with Ben Bleything) 0.26 0 1 0 5/8 79032
18. A Remote-Controlled Jukebox 0.20 0 1 0 n/a 32017
17. Testing, Debugging, Optimizing, and Documenting (Introduction) 0.50 0 1 1 0/0 7778
1. Running Code Only in Debug Mode 0.50 0 1 1 n/a 74380
2. Raising an Exception (written by Steve Arneil) 0.56 0 1 1 3/5 32387
3. Handling an Exception (written by Steve Arneil) 0.58 0 1 1 5/6 32398
4. Rerunning after an Exception (written by Steve Arneil) 0.60 0 1 1 3/3 32407
5. Adding Logging To Your Application 0.51 0 1 1 1/7 74388
6. Generating and Understanding Tracebacks 0.50 0 1 1 0/2 74371
7. Writing Unit Tests (written by Steve Arneil) 0.50 0 1 1 n/a 25256
8. Running Unit Tests (written by Steve Arneil) 0.50 0 1 1 n/a 25264
9. Testing Code that Uses External Resources (written by John-Mason Shackelford) 0.50 0 1 1 n/a 82826
10. Using breakpoint to Inspect and Change the State of Your Application 0.50 0 1 1 n/a 65551
11. Documenting Your Application 0.20 0 1 0 n/a 18250
12. Profiling Your Application 0.30 1 1 0 n/a 73424
13. Benchmarking Competing Solutions 0.50 0 1 1 0/3 74397
14. Running Multiple Analysis Tools at Once 0.20 0 1 0 n/a 74405
15. Who's Calling That Method? A Call Graph Analyzer 0.20 0 1 0 0/1 74414
18. Packaging and Distributing Software (Introduction) 0.70 1 1 1 1/1 7769
1. Finding Libraries by Searching Gem Repositories 0.60 1 1 1 n/a 12860
2. Installing and Using a Gem 0.73 0 2 1 1/3 13190
3. Requiring a Specific Version of a Gem 0.70 1 1 1 5/5 12870
4. Uninstalling a Gem 0.60 1 1 1 n/a 13207
5. Reading Documentation for Installed Gems 0.50 2 0 1 0/1 17852
6. Packaging Your Code as a Gem 0.50 2 0 1 n/a 13230
7. Distributing Your Gems 0.70 0 2 1 0/0 13443
8. Installing and Creating Standalone Packages With setup.rb 0.50 2 0 1 n/a 18738
19. Automating Tasks With Rake (Introduction) 0.50 0 1 1 n/a 7781
1. Automatically Running Unit Tests (written by Pat Eyler) 0.50 0 1 1 n/a 77577
2. Automatically Generating Documentation (written by Stefan Lang) 0.50 0 1 1 n/a 20982
3. Cleaning Up Generated Files (written by Stefan Lang) 0.40 1 0 1 n/a 79531
4. Automatically Building a Gem (written by Stefan Lang) 0.40 1 0 1 n/a 78999
5. Gathering Statistics About Your Code (written by Stefan Lang) 0.40 1 0 1 n/a 78666
6. Publishing Your Documentation (written by Stefan Lang) 0.40 1 0 1 n/a 79040
7. Running Multiple Tasks in Parallel 0.40 1 0 1 n/a 79021
8. A Generic Project Rakefile (written by Stefan Lang) 0.40 1 0 1 n/a 80092
20. Multitasking and Multithreading (Introduction) 0.60 1 1 1 0/0 7787
1. Forking a Daemon Process on Unix 0.70 0 2 1 n/a 23567
2. Creating a Windows Service (written by Bill Froelich) 0.00 0 0 0 n/a 85430
3. Doing Two Things At Once With Threads 0.70 0 2 1 0/3 32031
4. Synchronizing Access to an Object 0.47 0 2 0 2/3 77568
5. Terminating a Thread 0.70 0 2 1 0/6 74422
6. Running a Code Block on Many Objects Simultaneously 0.44 0 2 0 4/9 32071
7. Limiting Multithreading with a Thread Pool 0.70 0 2 1 0/2 74443
8. Driving an External Process with popen 0.75 0 2 1 2/4 32086
9. Capturing the Output and Error Streams from a Unix Shell Command 0.75 0 2 1 1/2 32094
10. Controlling a Process on Another Machine 0.70 0 2 1 n/a 32509
11. Avoiding Deadlock 0.70 0 2 1 n/a 77538
21. User Interface (Introduction) 0.70 0 2 1 0/0 7793
1. Getting Input One Line at a Time 0.70 0 2 1 n/a 23588
2. Getting Input One Character at a Time 0.70 0 2 1 n/a 26961
3. Parsing Command-Line Arguments 0.70 0 2 1 n/a 32000
4. Testing Whether a Program Is Running Interactively 0.70 0 2 1 n/a 32477
5. Setting Up and Tearing Down a Curses Application 0.70 0 2 1 n/a 32339
6. Clearing the Screen 0.70 0 2 1 n/a 32009
7. Determining Terminal Size 0.70 0 2 1 0/4 32370
8. Changing Text Color 0.80 0 2 1 2/2 32378
9. Reading a Password 0.70 0 2 1 n/a 32442
10. Allowing Input Editing with Readline 0.80 0 2 1 1/1 74337
11. Making Your Keyboard Lights Blink 0.70 0 2 1 n/a 78728
12. Creating a GUI Application with Tk (written by Kevin Marshall) 0.50 0 1 1 n/a 76067
13. Creating a GUI Application with wxRuby 0.30 0 0 1 n/a 76324
14. Creating a GUI Application with Ruby-GTK 0.30 0 0 1 n/a 79076
15. Creating a Mac OS X Application with RubyCocoa (written by Alun ap Rhisiart) 0.00 0 0 0 n/a 81746
16. Talking to AppleScript to get User Input 0.20 0 1 0 n/a 78756
22. Extending Ruby with Other Languages (written by Garrett Rooney) (Introduction) 0.10 1 0 0 0/0 7799
1. Writing a C Extension for Ruby (written by Garrett Rooney) 0.50 0 1 1 n/a 22835
2. Using a C Library from Ruby (written by Garrett Rooney) 0.50 0 1 1 n/a 22839
3. Calling a C Library through Swig (written by Garrett Rooney) 0.40 1 0 1 n/a 23254
4. Writing C Within Your Ruby Code (written by Garrett Rooney) 0.40 1 0 1 n/a 23303
5. Calling Java Libraries with JRuby (written by Thomas Enebo) 0.10 1 0 0 n/a 79177
23. System Administration (Introduction) 0.80 1 2 1 0/0 7796
1. Scripting an External Program 0.90 1 2 1 2/2 74314
2. Managing Windows Services (written by Bill Froelich) 0.20 0 1 0 n/a 85238
3. Running Code as Another User 0.72 2 1 1 1/4 74628
4. Running Periodic Tasks Without Cron or At 0.70 2 1 1 n/a 76105
5. Deleting Files that Match a Regular Expression (written by Matthew Palmer) 0.83 1 2 1 1/3 23595
6. Renaming Files in Bulk 0.90 1 2 1 3/3 35436
7. Finding Duplicate Files 0.80 1 2 1 n/a 76131
8. Automating Backups 0.80 1 2 1 0/6 75847
9. Normalizing Ownership and Permissions in User Directories 0.80 1 2 1 n/a 76345
10. Killing all Processes For A Given User 0.90 0 3 1 0/1 32103

341 recipes in 23 chapters.

273 were run through the automated tester, which could detect the success of 80.21% (2279) of the 1828 tests.

The contributors wrote 62 recipes and 1 chapter intro.


This document (source) is part of Crummy, the webspace of Leonard Richardson (contact information). It was last modified on Wednesday, May 23 2007, 20:13:11 Nowhere Standard Time and last built on Thursday, October 02 2014, 00:00:05 Nowhere Standard Time.

Crummy is © 1996-2014 Leonard Richardson. Unless otherwise noted, all text licensed under a Creative Commons License.

Document tree:

http://www.crummy.com/
writing/
RubyCookbook/
Site Search: