# Snippets databases

**URL:** <https://www.ruby-forum.com/t/snippets-databases/109433>\
**Category:** Ruby\
**Created:** [July 14, 2007, 8:33pm UTC](https://www.ruby-forum.com/t/snippets-databases/109433 "2007-07-14T20:33:22Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![sy1234](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8e7dd6/32.png) [@sy1234](https://www.ruby-forum.com/u/sy1234)\
**Post date:** [July 14, 2007, 8:33pm UTC](https://www.ruby-forum.com/t/snippets-databases/109433/1 "2007-07-14T20:33:22Z")

</div>

This is a longish post… there were bunches of ideas rattling around in  
my head.

I’ve been wondering how I can manage my snippets of code. I try to  
experiment with self-contained examples whenever I have a particularly  
interesting problem I want to remember the solution to. But it’s all  
disorganized, and sometimes it’s housed past my **END** statements at  
the end of various half-finished scripts. That’s a great way to lose my  
snippets. =)

It’s a horror for me to suspect that I know how to solve a problem, and  
that I’ve done it before, and not quite remember how I did it before  
because I can’t find that one block of code.

The one thing I know about myself is that I will never entirely and  
reliably remember enough of my past solutions. I know this is  
unrealistic for most people but I know that it’s entirely impossible for  
me. Nomatter how I absorb myself with something, I’ll always forget  
bits of the knowledge. On the plus side, this makes me great with  
documentation since I write everything down. =)

So, I want to house all of my snippets within a useful and  
easily-used/searched documentation structure of some kind. Because this  
is an itch, my personal rule/habit is for me to lay down some code to  
solve the problem for myself. But this seems like a large-ish project.

What I really wanted to learn is:

Do you use a snippets-helper of some kind? If so, what?  
Do you think it’s a good idea for me to make my own tool and then  
outgrow it and use someone else’s afterwards?

It’s not a problem for me to reach out and find a couple of dozen  
websites and applications which would solve this problem. But I just  
wanted to hear some opinions/testimonials for existing tools. Some  
people may use some interesting solutions that I might not find by  
googling.

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.

---

<div class="post-metadata">

**Author:** ![sy1234](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8e7dd6/32.png) [@sy1234](https://www.ruby-forum.com/u/sy1234)\
**Post date:** [July 14, 2007, 9:05pm UTC](https://www.ruby-forum.com/t/snippets-databases/109433/2 "2007-07-14T21:05:24Z")

</div>

On Jul 14, 2007, at 11:31 AM, sy1234 wrote:

> outgrow it and use someone else’s afterwards?  
> few fields, each are searchable: topic(s), title, abstract,  
> 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.

Have you considered just setting up a blog (public or private). The  
typical features therein would cover most of what you mentioned. Use  
tags to help categorize and create refined searches. Comments to  
keep notes, titles. The body could be your abstract + the code.

A second option might be to put your Abstract + Snippet up as a  
Pastie and then file them with [del.icio.us](http://del.icio.us).

If you’re looking for software, there’s four or five competing  
organizers for Macs. Most have silly names I can’t remember. Since I  
don’t use any of these products, don’t consider this an endorsement,  
but Yojimbo comes to mind.

Corey

---

<div class="post-metadata">

**Author:** ![sy1234](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8e7dd6/32.png) [@sy1234](https://www.ruby-forum.com/u/sy1234)\
**Post date:** [July 14, 2007, 10:28pm UTC](https://www.ruby-forum.com/t/snippets-databases/109433/3 "2007-07-14T22:28:30Z")

</div>

On 7/14/07, sy1234 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> some other stuff. I’d learn a bit of database stuff and some helpful  
> 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.

I think that is a good idea to start doing learning tests  
([http://c2.com/cgi-bin/wiki?LearningTest](http://c2.com/cgi-bin/wiki?LearningTest)). Just organize your  
self-contained examples in unit test cases and give them proper names.  
Then “grep” will do.

---

<div class="post-metadata">

**Author:** ![sy1234](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8e7dd6/32.png) [@sy1234](https://www.ruby-forum.com/u/sy1234)\
**Post date:** [July 14, 2007, 10:56pm UTC](https://www.ruby-forum.com/t/snippets-databases/109433/4 "2007-07-14T22:56:31Z")

</div>

On 7/14/07, Aureliano C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I think that is a good idea to start doing learning tests  
> ([http://c2.com/cgi-bin/wiki?LearningTest](http://c2.com/cgi-bin/wiki?LearningTest)). Just organize your  
> self-contained examples in unit test cases and give them proper names.  
> Then “grep” will do.

I did this while dabbling with Haskell. Definitely recommendable.

---

<div class="post-metadata">

**Author:** ![sy1234](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8e7dd6/32.png) [@sy1234](https://www.ruby-forum.com/u/sy1234)\
**Post date:** [July 14, 2007, 11:09pm UTC](https://www.ruby-forum.com/t/snippets-databases/109433/5 "2007-07-14T23:09:32Z")

</div>

On 7/14/07, sy1234 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> some other stuff. I’d learn a bit of database stuff and some helpful  
> 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.

I usually pastie it with a =begin/=end block at the top explaining it,  
then I [del.icio.us](http://del.icio.us) that pastie. It’s pretty simple, and you can tag  
and search.

---

<div class="post-metadata">

**Author:** ![sy1234](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8e7dd6/32.png) [@sy1234](https://www.ruby-forum.com/u/sy1234)\
**Post date:** [July 15, 2007, 6:49am UTC](https://www.ruby-forum.com/t/snippets-databases/109433/6 "2007-07-15T06:49:00Z")

</div>

Gregory B. said the following on 07/14/2007 04:55 PM:

> On 7/14/07, Aureliano C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > I think that is a good idea to start doing learning tests  
> > ([http://c2.com/cgi-bin/wiki?LearningTest](http://c2.com/cgi-bin/wiki?LearningTest)). Just organize your  
> > self-contained examples in unit test cases and give them proper names.  
> > Then “grep” will do.
> 
> I did this while dabbling with Haskell. Definitely recommendable.

I can’t believe I didn’t remember this. I’ve even had this mentioned  
before. This is definitely something I ought to get into!

I could also hack together a little search tool which would help me  
search through the headers for my keywords or abstracts. Ooh… I like  
it.

---

<div class="post-metadata">

**Author:** ![sy1234](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8e7dd6/32.png) [@sy1234](https://www.ruby-forum.com/u/sy1234)\
**Post date:** [July 15, 2007, 6:47am UTC](https://www.ruby-forum.com/t/snippets-databases/109433/7 "2007-07-15T06:47:00Z")

</div>

Corey J. said the following on 07/14/2007 03:04 PM:

> Have you considered just setting up a blog (public or private). The  
> typical features therein would cover most of what you mentioned. Use  
> tags to help categorize and create refined searches. Comments to keep  
> notes, titles. The body could be your abstract + the code.

A blog might not be a bad idea. Right now I’ve got some notes dumped  
into my wiki:

> **[Register4Less.com Parking Page for jrandomhacker.info](http://www.jrandomhacker.info/Ruby_code_snippets)**
>
> Parking page for domain jrandomhacker.info registered with Register4Less.com.

But searchability goes _way_ down, unless I start using categories as  
tags… but it’s still messy unless I begin using namespaces and all  
sorts of other nonsense. Basically my non-snippets efforts would get in  
the way.

But something specialized which could also do code highlighting or even  
some code execution like how Chris P.'s tutorial is set up – that  
would be interesting.

Argh, I’m craving a hand-coded solution…

Ok, a blog is an interesting idea. I’ll note it.

> A second option might be to put your Abstract + Snippet up as a Pastie  
> and then file them with [del.icio.us](http://del.icio.us).
> 
> If you’re looking for software, there’s four or five competing  
> organizers for Macs. Most have silly names I can’t remember. Since I  
> don’t use any of these products, don’t consider this an endorsement,  
> but Yojimbo comes to mind.  
> My first impression was negative. I think my main reasoning is the fact  
> that someone else would own that setup. Is there an easy way for me to  
> back up my snippets database?

I’ll write down a set of questions and check them off when I’m  
researching this as a solution.

Thanks for the tips…

---

<div class="post-metadata">

**Author:** ![sy1234](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8e7dd6/32.png) [@sy1234](https://www.ruby-forum.com/u/sy1234)\
**Post date:** [July 15, 2007, 6:51am UTC](https://www.ruby-forum.com/t/snippets-databases/109433/8 "2007-07-15T06:51:00Z")

</div>

Chris C. said the following on 07/14/2007 05:07 PM:

> I usually pastie it with a =begin/=end block at the top explaining it,  
> then I [del.icio.us](http://del.icio.us) that pastie. It’s pretty simple, and you can tag  
> and search.  
> I’m leaning towards test cases now… but adding good headers would  
> definitely be nice. Plus I could probably unleash some third-party  
> documentation engine on the test snippets tree and have it build a fancy  
> browser-accessible interface…
