Mega Code Archive
Search
.Net
ASP .Net
ASP .Net Tutorial
C#
C# Book
C# by API
C# Tutorial
VB.Net
VB.Net by API
VB.Net Tutorial
Visual C++ .Net
VisualBasic Script
Java
Java
Java Book
Java by API
Java Tutorial
Script
Flash ActionScript
Flex
JavaScript DHTML
JavaScript Reference
JavaScript Tutorial
Database
MSSQL
MSSQL Tutorial
MySQL
MySQL Tutorial
Oracle PLSQL
Oracle PLSQL Tutorial
PostgreSQL
Languages
Android
C
C Tutorial
C++
C++ Tutorial
Delphi
Perl
PHP
Python
Python Tutorial
Ruby
Silverlight
Office
MSOfficeExcel 2007 Tutorial
MSOfficePowerPoint 2007 Tutorial
MSOfficeWord 2007 Tutorial
Data
XML
XML Tutorial
Ruby
Development 200 codes
Home
Ruby
Development
1 $KCODE = u
2 $KCODE Demo
3 1 refers to the match of the first group
4 A pattern that matches a string containing the text Perl or the text Python
5 Add a new method with eval
6 Add function to Math module
7 Adding a Timeout to a Long-Running Operation
8 Adding Logging To Your Application
9 An example of a regular expression used to match a string with the String method scan
10 An unescaped vertical bar() matches either the regular expression that precedes it or the regular expression that follows it.t
11 Append to a zip file
12 ARGF ($) is a virtual concatenation of all the files that appear on the command line
13 ARGF gets
14 ARGV and ARGF
15 Assign value to ARGV
16 Backslash Sequences in the Substitution
17 Because measure accepts code blocks, you can make it as elaborate
18 Benchmark includes a way to make completing multiple tests more convenient
19 Benchmark inline c
20 Benchmark reflection
21 Call GC to do a garbage collection
22 Call to the class method sqrt from the Math module
23 Check string size for non ascii code
24 Checking a Credit Card Checksum
25 Chomp takes off any Enters hanging out at the end of your string
26 Compressing and Archiving Files with Gzip and Tar
27 Convert polar coordinates to Cartesian coordinates
28 Convert the Cartesian point (x,y) to polar (magnitude, angle) coordinates
29 Converting From One Encoding to Another
30 Count for five second
31 Count non-ascii string
32 Create a class to represent the structure of the data
33 Create a zero-length file with a system command
34 Create data for CSV file
35 Create your own type of exception if you wanted to
36 Daemon Processes
37 Disabling the Garbage Collector
38 Do natural logarithms (base E or Euler) and base-10 logarithms
39 Doing Aspect-Oriented Programming
40 Easy OS Detection with RUBY_PLATFORM
41 Embedded in the string are a pair of template tags, %= and %
42 Embedded Ruby
43 Environment Variables
44 ERB tags in a string
45 ERB template tags
46 Euler and PI
47 Eval with variable name
48 Evaluation with variable
49 Exc to_s Returns the message associated with this exception
50 Exceprtion hierarchy
51 Exception success Returns true is the exit status if nil or zero
52 Execute an eval in a thread
53 Execution is transferred to a different program, and the current program ceases immediately-the second line is never executed.
54 Field types for sprintf
55 Find the people in your database whose ages are between 20 and 40
56 Finding Libraries by Searching Gem Repositories rb
57 Generate from array
58 Generate random numbers
59 Generating Random Numbers
60 Generator based on regualr expression
61 Get a random item in an array
62 Get a random value in a hash
63 Get command line input through ARGV
64 Get hmean value
65 Get mean value
66 Get sigma value
67 Get the median value
68 Get the mode value
69 Get users input and process it, ignoring comments and exiting when the user enters the word quit
70 Get variance value
71 Getting Results from Other Programs
72 Grep([(d{3})]d{3}-d{4})
73 Grep([(d+)]d+-d+)
74 Grep([(ddd)]ddd-dddd)
75 Grep(^When in)
76 Grep(Aen in)
77 Grep(colour)
78 Grep(e n,z)
79 Grep(m(ea)n)
80 Grep(m[ae]n)
81 Grep(men)
82 Grep(menman)
83 Grep(outcast state,$)
84 Handling International Encodings
85 Have Repetition match the minimum by adding a question mark suffix
86 If we create our own exception classes, they need to be subclasses of either class Exception or one of its descendants
87 Implementing Class and Singleton Methods
88 Inflate and deflate a string
89 Install rails
90 Installing and Using a Gem
91 Installing RubyInline on Unix-related platforms
92 Keep data for the current month only
93 Keep data for today and the past 20 days
94 Length of non-ascii string
95 Loading the data from a CSV-formatted file into an array is with CSV read
96 Looking for a word
97 Loop through gems cache
98 Looping Through Multiple Iterables in Parallel
99 Marshal a set
100 Marshal a string
101 Match a regular repression in if statement
102 Match a time
103 Match a time such as 12
104 Match one of a group of characters within apattern
105 Match operator demo
106 Match operators return the character position at which the match occurred
107 Match Perl, a space, and Python
108 Match Perl, one or more spaces, and Python
109 Match Perl, whitespace characters, then Python
110 Match Perl, zero or more other chars, then Python
111 Match Perl, zero or more spaces, and Python
112 Match Ruby, a space, and either Perl or Python
113 MatchData-related $-variables are in $~
114 Math const_set and get
115 Math functions from the Math module
116 Nested ERB block
117 Parse command line
118 Parse one CSV file line
119 Pick out the first person in the data called Laura
120 Print out time in Begin and end block
121 Print Statement
122 Print vs puts
123 Printf prints its arguments under the control of a format string
124 Printf with format
125 Printf(% 55f, 1 8 + 0 1)
126 Printf(% 55f, 1 9)
127 Prints nil
128 Process pid and Process ppid
129 Profiling Your Application
130 Random number
131 Random seeds
132 Random with a range
133 Read a line of input into $_
134 Read CSV file
135 Read text from the command line, assigns that text to the predefined variable $_
136 Read your name from keyboard
137 Reading and Searching CSV Data
138 Regexps use elements to instruct the regular expression engine on how to find a given string
139 Repetition
140 Replace every occurrence of Perl and Python with Ruby
141 Replace Perl or Python with Ruby
142 Retrieve the data from the PStore database
143 Return the gmean value
144 Ruby Documentation
145 Ruby exception hierarchy
146 Ruby method chomp removes that newline character from the end of the text in the $_ variable
147 Ruby places parameters that are appended to the command line into a special array called ARGV
148 Ruby profiler
149 Ruby to SQL Type Conversion
150 Run an operating system command with system
151 Run notepad exe with system function
152 Saving Data Back to the CSV File
153 Search for a word from the very beginning
154 Setting the $KCODE global variable to u and loading jcode gives regular expressions awareness of UTF-8 characters
155 Simple Benchmarking
156 Some random numbers based on process number and current time
157 Sprintf Flags and Field Types
158 Sprintf( %0 2f, my_bmi )
159 SQL to Ruby Type Conversion
160 Start the log over whenever the log exceeds 100 megabytes in size
161 Start the seed with the number 1
162 Status fo an exception
163 Sub and gsub replace with regular expressions
164 Submit each part of a command separately, as an argument to system
165 Taking Logarithms
166 The match operator =~ can be used to match a string against a regular expression
167 The Math exp function returns Euler to the power of x
168 The Math Object
169 The method Regexp#match matches a regular expression against a string
170 The Methods gets and chomp
171 The part of a string matched by a regular expression can be replaced
172 The simplest way to get external data into a program is to use the keyboard
173 The two filenames are both command line arguments
174 To find out what constants Math (or any other module or class) has defined, use reflection by invoking the constants method.tx
175 Unescape HTML
176 Uninstalling a Gem rb
177 Update a CSV file
178 Use back references to match delimiters
179 Use CSV alongside the File class
180 Use environment variables to decide where to store temporary files
181 Use eval to run a statement dynamically
182 Use gem to get library version
183 Use gets method to read from standard input (text from your keyboard, by default)
184 Use parentheses to group terms within a regular expression
185 Use parentheses within patterns,just as you can in arithmetic expressions
186 Use part of the current match later in that match allows you to look for various forms of repetition
187 Use printf to print the output to your display (the default standard output device)
188 Use Process kill
189 Use Process wait to wait for all child processes to finish before continuing
190 Use scanf
191 Use shell command wrapper through shell library
192 Use sprintf(%08b, num) to convert input to binary number
193 Use while loop to read a command
194 Using jcode you can make regular expressions UTF-8 aware
195 Validate an email address
196 Validate an email address with Resolv
197 Write a factorial method in C using RubyInline
198 You can also specify repetition within patterns
199 You dont need to use $_ with gets - you can assign the text it reads to any variable
200 Your own math function