snippets databases

Discussion in 'Ruby' started by sy1234, Jul 14, 2007.

  1. sy1234

    sy1234 Guest

    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.
     
    sy1234, Jul 14, 2007
    #1
    1. Advertising

  2. sy1234

    Corey Jewett Guest

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

    > 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.


    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.

    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
     
    Corey Jewett, Jul 14, 2007
    #2
    1. Advertising

  3. On 7/14/07, sy1234 <> wrote:
    > 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. No matter 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.
    >


    I think that is a good idea to start doing learning tests
    (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.
     
    Aureliano Calvo, Jul 14, 2007
    #3
  4. On 7/14/07, Aureliano Calvo <> wrote:

    > I think that is a good idea to start doing learning tests
    > (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.
     
    Gregory Brown, Jul 14, 2007
    #4
  5. sy1234

    Chris Carter Guest

    On 7/14/07, sy1234 <> wrote:
    > 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.
    >
    >
    >
    >


    I usually pastie it with a =begin/=end block at the top explaining it,
    then I del.icio.us that pastie. It's pretty simple, and you can tag
    and search.

    --
    Chris Carter
    concentrationstudios.com
    brynmawrcs.com
     
    Chris Carter, Jul 14, 2007
    #5
  6. sy1234

    sy1234 Guest

    Corey Jewett 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:
    http://jrandomhacker.info/Ruby_code_snippets

    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 Pine'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.
    >
    > 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..
     
    sy1234, Jul 15, 2007
    #6
  7. sy1234

    sy1234 Guest

    Gregory Brown said the following on 07/14/2007 04:55 PM:
    > On 7/14/07, Aureliano Calvo <> wrote:
    >> I think that is a good idea to start doing learning tests
    >> (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.
     
    sy1234, Jul 15, 2007
    #7
  8. sy1234

    sy1234 Guest

    Chris Carter 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 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..
     
    sy1234, Jul 15, 2007
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. - Steve -

    Reusing Code Snippets

    - Steve -, Sep 30, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    427
    Greg Burns
    Oct 1, 2004
  2. Pat

    Where are my Code Snippets?

    Pat, Apr 20, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    396
    Simon Harris
    Apr 23, 2005
  3. Steve Franks
    Replies:
    2
    Views:
    364
    Juan T. Llibre
    Sep 11, 2005
  4. Edwin Knoppert
    Replies:
    0
    Views:
    372
    Edwin Knoppert
    Nov 30, 2005
  5. Ken North
    Replies:
    0
    Views:
    605
    Ken North
    Jul 14, 2005
Loading...

Share This Page