Mostly hosted on https://github.com/spiralofhope/ruby-random/tree/master
listing available signals ∞
It's a bit ugly, but it works.
exit Signal.list.each { |i| print i puts "" }
Notes ∞
-
Find the errata notes
- Print the errata notes
-
regex comments - 324
#!/usr/bin/env ruby
# = . so that GC#start is actually GC.start .. I don't know why.
ri --help
for env settings
using ri in ruby - p 191
just rdoc
to make html under doc/
rdoc --ri rdoc --ri-site
p 213 has a nice example of RDoc use
p. 127 - IO - File, BasicSocket (763)
Kernel::
gets, open, print, printf, putc, puts, readline, readlines, test (p 516)
modes: read, write, etc.. p. 504
File.new - permissions .. 470
- IO.foreach (131)
instead of tests, use rescue to handle IO exeptions, then the tests do things which cause exceptions! =)
- 132 - use << to put stuff into a file
151 - unit testing
desc - all items read from a file are _tainted_ -- p 399 safe level 1
159 - put the tests in
ruby test_x.rb (like test_desc.rb)
put test in a test/ directory
cd test ruby ../test/test_x.rb
p 160 has some magic for this
- 108 - exceptions
- re-raise
-
use
$!
use array.at(#)
because it's faster.
use array.new
?? not a=[]
??
-
or instead of killing a[0], I could arr.compact?
from array to string:
a = [1, 2, 3] a * " " => "1, 2, 3"
Using "*" is ".join"
-
I could build an array replacing the colour codes with ANSI colour codes, then return a string. What are the ansi codes? a.collect is a good way to do it (search/replace)
Is it possible to communicate between ruby threads by changing the type of an object?
distributed ruby safety? Can I use this for executing code on an untrusted client?
idea: erb + mediawiki ∞
- optionally send arguments
- optionally display the original code
- optionally display the result
-
colourize the output or the code
cheap rsync ∞
Some quick code that was whipped up to duplicate rsync appending functionality.
https://web.archive.org/web/20070615023341/http://eigenclass.org:80/hiki.rb?cheap+rsync
rio ∞
https://web.archive.org/web/20210511020206/http://rio4ruby.com/rio/
Rio is a convenience class wrapping much of the functionality of IO, File, Dir, Pathname, FileUtils, Tempfile, StringIO, and OpenURI and uses Zlib, and CSV to extend that functionality using a simple consistent interface. Most of the instance methods of IO, File and Dir are simply forwarded to the appropriate handle to provide identical functionality. Rio also provides a "grande" interface that allows many application level IO tasks to be expressed succinctly.
Cool examples:
Iterate over the .rb
files in a directory and its subdirectories:
rio('adir').all.files('*.rb') { |entrio| ... }
Iterate over only the files in a directory:
rio('adir').files { |entrio| ... }
Iterate over the entries in a directory:
rio('adir').entries { |entrio| ... }
See:
- https://web.archive.org/web/20200219181508/http://rio4ruby.com/rio/RIO/Doc/INTRO.html
- https://web.archive.org/web/20200219181437/http://rio4ruby.com/rio/RIO/Doc/HOWTO.html
- https://web.archive.org/web/20200219181338/http://rio4ruby.com/rio/RIO/Doc/EXAMPLES.html
-
https://web.archive.org/web/20191221131317/http://rio4ruby.com/rio/RIO/Doc/OPTIONAL.html
Other snippets solutions ∞
-
test cases, manually-organized. Give good names, and create internal abstracts in their header
=begin
/=end
block.- Then create a helpful front-end to search for things. This could work.
- This could even be expanded into a web-interface using an existing tool. Oh the possibilities.. neato.
- google for various random solutions - awaiting some testimonials and feedback.
- a blog, with nice tagging and such
- a self-created setup - like Chris Pine's website.. I've always wanted to do something like that.
-
del.icio.us -- put up an abstract + snippet "pastie" (to research)
=begin
/=end
block for comments.- can I edit / organize snippets later?
- can I back up my info?
- can I restore my info?
- is there an API? Can I use a local program to access/change my snippets?
apps mentioned:
-
Yojimbo
Some of my earlier thoughts:
But a self-created database feel simple on the surface -- just a few fields, each are searchable: topic(s), title, abstract, keywords, code code, example code, example output, 'see also' links, notes and maybe some other stuff. I'd learn a bit of database stuff and some helpful new libraries. It sounds like a definable project whose completion-payoff would be incalculable. Actually, it sounds like a Rails project, but I'm not ready to go there.
But I kindof imagine being able to search through all of my existing projects to find real-world examples of the code in use. And then I could somehow embed comments within my code which talked about the code and helped the searchability. That's definitely way over my head, but if it were implemented elsewhere I'd love to use it.
There are some nice documentation systems out there but they seem focused around single-project documentation and not on gathering info and searching through an entire messy and unrelated collection of scripts like what I'd want.
Code snippet resources ∞
- https://web.archive.org/web/20131003183036/http://rubyforge.org/snippet/browse.php?by=lang&lang=17
- https://web.archive.org/web/20070129010930/http://bigbold.com/snippets/tag/ruby
- https://web.archive.org/web/20081015161217/http://textsnippets.com/tags/ruby
-
https://web.archive.org/web/20090715060151/http://www.devdaily.com/blog/Content/1/19/
--
- https://web.archive.org/web/20070709214357/http://ruby.codezoo.com/ -- Was an application database.
Working with strings ∞
Last updated 2025-02-08 at 19:52:19