Thread: Code snippet hosting?

Code snippet hosting?

From
Peter Eisentraut
Date:
People often post a function, a script, or a complex query that is 
general enough to be worth keeping but perhaps not appropriate for 
pgfoundry or the documentation.  MySQL has a code snippet service for 
that: <http://forge.mysql.com/tools/>.  I think something like this 
would be quite useful for PostgreSQL as well.  Perhaps the wiki could be 
used for that; I'm not sure.

Ideas anyone?


Re: Code snippet hosting?

From
Mike Ellsworth
Date:
On Thu, Mar 19, 2009 at 10:34 AM, Peter Eisentraut <peter_e@gmx.net> wrote:
> People often post a function, a script, or a complex query that is general
> enough to be worth keeping but perhaps not appropriate for pgfoundry or the
> documentation.  MySQL has a code snippet service for that:
> <http://forge.mysql.com/tools/>.  I think something like this would be quite
> useful for PostgreSQL as well.  Perhaps the wiki could be used for that; I'm
> not sure.
>
> Ideas anyone?

No ideas for implementation - but it would be a great service to the
community and a big + for Advocacy.


Re: Code snippet hosting?

From
Brendan Jurd
Date:
On Fri, Mar 20, 2009 at 1:34 AM, Peter Eisentraut <peter_e@gmx.net> wrote:
> People often post a function, a script, or a complex query that is general
> enough to be worth keeping but perhaps not appropriate for pgfoundry or the
> documentation.  MySQL has a code snippet service for that:
> <http://forge.mysql.com/tools/>.  I think something like this would be quite
> useful for PostgreSQL as well.  Perhaps the wiki could be used for that; I'm
> not sure.

Cool idea.  With a little massaging the wiki could accomodate this ...
there are syntax highlighting plugins we could install to get the code
snippets looking nice.  Wouldn't be as fancy as the MySQL site you
linked, but it would do the job.

Cheers,
BJ


Re: Code snippet hosting?

From
Alvaro Herrera
Date:
Brendan Jurd escribió:
> On Fri, Mar 20, 2009 at 1:34 AM, Peter Eisentraut <peter_e@gmx.net> wrote:
> > People often post a function, a script, or a complex query that is general
> > enough to be worth keeping but perhaps not appropriate for pgfoundry or the
> > documentation.  MySQL has a code snippet service for that:
> > <http://forge.mysql.com/tools/>.  I think something like this would be quite
> > useful for PostgreSQL as well.  Perhaps the wiki could be used for that; I'm
> > not sure.
> 
> Cool idea.  With a little massaging the wiki could accomodate this ...
> there are syntax highlighting plugins we could install to get the code
> snippets looking nice.

+1

Just make sure there are appropriate category tags.

Maybe we should use a separate namespace for this?  Snippet: or
something like that ... not sure if this is a good idea.

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.


Re: Code snippet hosting?

From
Brendan Jurd
Date:
On Fri, Mar 20, 2009 at 2:31 AM, Alvaro Herrera
<alvherre@commandprompt.com> wrote:
>
> +1
>
> Just make sure there are appropriate category tags.

Indeed.  If we use categories properly, that gives us (for free) an
alphabetical index of all available snippets.

>
> Maybe we should use a separate namespace for this?  Snippet: or
> something like that ... not sure if this is a good idea.

I'm lukewarm about creating a namespace for it.  I reckon we could
just allow people to create pages for their snippets and if at some
future time we start getting into page name collisions, we cross that
bridge.  Another option, if the snippets start cluttering up the Main
namespace, is to make them subpages.

So, anybody got a useful code snippet they would like to volunteer as
a first test subject? =)  Failing that, we could write up the
Mandelbrot recursive query demo.

Cheers,
BJ


Re: Code snippet hosting?

From
"Gavin M. Roy"
Date:
It wouldn't be hard for me to rebrand <a href="http://privatepaste.com">privatepaste.com</a> and add the few additional
pieces(and perhaps remove others) for this.<br /><br /><div class="gmail_quote">On Thu, Mar 19, 2009 at 10:34 AM, Peter
Eisentraut<span dir="ltr"><<a href="mailto:peter_e@gmx.net">peter_e@gmx.net</a>></span> wrote:<br /><blockquote
class="gmail_quote"style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">People often post a function,
ascript, or a complex query that is general enough to be worth keeping but perhaps not appropriate for pgfoundry or the
documentation. MySQL has a code snippet service for that: <<a href="http://forge.mysql.com/tools/"
target="_blank">http://forge.mysql.com/tools/</a>>. I think something like this would be quite useful for PostgreSQL
aswell.  Perhaps the wiki could be used for that; I'm not sure.<br /><br /> Ideas anyone?<br /><font
color="#888888"><br/> -- <br /> Sent via pgsql-www mailing list (<a href="mailto:pgsql-www@postgresql.org"
target="_blank">pgsql-www@postgresql.org</a>)<br/> To make changes to your subscription:<br /><a
href="http://www.postgresql.org/mailpref/pgsql-www"target="_blank">http://www.postgresql.org/mailpref/pgsql-www</a><br
/></font></blockquote></div><br/> 

Re: Code snippet hosting?

From
Alvaro Herrera
Date:
Brendan Jurd escribió:

> So, anybody got a useful code snippet they would like to volunteer as
> a first test subject? =)  Failing that, we could write up the
> Mandelbrot recursive query demo.

I support the Mandelbrot query as the first snippet :-)

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.


Re: Code snippet hosting?

From
David Blewett
Date:
On Thu, Mar 19, 2009 at 10:34 AM, Peter Eisentraut <peter_e@gmx.net> wrote:

>  I think something like this would be quite
> useful for PostgreSQL as well.  Perhaps the wiki could be used for that; I'm
> not sure.

Django has something like that [1]. Just a thought.

David Blewett

1. http://www.djangosnippets.org/about


Re: Code snippet hosting?

From
"Joshua D. Drake"
Date:
On Thu, 2009-03-19 at 11:45 -0400, Alvaro Herrera wrote:
> Brendan Jurd escribió:
> 
> > So, anybody got a useful code snippet they would like to volunteer as
> > a first test subject? =)  Failing that, we could write up the
> > Mandelbrot recursive query demo.
> 
> I support the Mandelbrot query as the first snippet :-)


Why wouldn't we just use the wiki for this?

Joshua D. Drake


> 
> -- 
> Alvaro Herrera                                http://www.CommandPrompt.com/
> The PostgreSQL Company - Command Prompt, Inc.
> 
-- 
PostgreSQL - XMPP: jdrake@jabber.postgresql.org  Consulting, Development, Support, Training  503-667-4564 -
http://www.commandprompt.com/ The PostgreSQL Company, serving since 1997
 



Re: Code snippet hosting?

From
Alvaro Herrera
Date:
Joshua D. Drake escribió:
> On Thu, 2009-03-19 at 11:45 -0400, Alvaro Herrera wrote:
> > Brendan Jurd escribió:
> > 
> > > So, anybody got a useful code snippet they would like to volunteer as
> > > a first test subject? =)  Failing that, we could write up the
> > > Mandelbrot recursive query demo.
> > 
> > I support the Mandelbrot query as the first snippet :-)
> 
> Why wouldn't we just use the wiki for this?

Please go have some coffee and reread the thread :-)

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.


Re: Code snippet hosting?

From
Brendan Jurd
Date:
On Fri, Mar 20, 2009 at 2:52 AM, Joshua D. Drake <jd@commandprompt.com> wrote:
> On Thu, 2009-03-19 at 11:45 -0400, Alvaro Herrera wrote:
>> Brendan Jurd escribió:
>>
>> > So, anybody got a useful code snippet they would like to volunteer as
>> > a first test subject? =)  Failing that, we could write up the
>> > Mandelbrot recursive query demo.
>>
>> I support the Mandelbrot query as the first snippet :-)
>
> Why wouldn't we just use the wiki for this?

Um.  That's ... what we're talking about?

The conversation you're quoting was about which piece of code we might
use, to start playing with a wiki implementation.

Cheers,
BJ


Re: Code snippet hosting?

From
"Joshua D. Drake"
Date:
On Fri, 2009-03-20 at 02:55 +1100, Brendan Jurd wrote:
> On Fri, Mar 20, 2009 at 2:52 AM, Joshua D. Drake <jd@commandprompt.com> wrote:
> > On Thu, 2009-03-19 at 11:45 -0400, Alvaro Herrera wrote:
> >> Brendan Jurd escribió:
> >>
> >> > So, anybody got a useful code snippet they would like to volunteer as
> >> > a first test subject? =)  Failing that, we could write up the
> >> > Mandelbrot recursive query demo.
> >>
> >> I support the Mandelbrot query as the first snippet :-)
> >
> > Why wouldn't we just use the wiki for this?
> 
> Um.  That's ... what we're talking about?
> 
> The conversation you're quoting was about which piece of code we might
> use, to start playing with a wiki implementation.

Oh. Well I think I will go do what Alvaro just suggested.

Joshua D. Drake


> 
> Cheers,
> BJ
> 
-- 
PostgreSQL - XMPP: jdrake@jabber.postgresql.org  Consulting, Development, Support, Training  503-667-4564 -
http://www.commandprompt.com/ The PostgreSQL Company, serving since 1997
 



Re: Code snippet hosting?

From
Josh Berkus
Date:
On 3/19/09 7:34 AM, Peter Eisentraut wrote:
> People often post a function, a script, or a complex query that is
> general enough to be worth keeping but perhaps not appropriate for
> pgfoundry or the documentation. MySQL has a code snippet service for
> that: <http://forge.mysql.com/tools/>. I think something like this would
> be quite useful for PostgreSQL as well. Perhaps the wiki could be used
> for that; I'm not sure.

Yeah, this was *supposed* to be a feature of GForge when we adopted it.  It wasn't until after we lit up GForge and
movedthe accounts over 
 
from GBorg that Tim let me know that the snippets stuff didn't work and 
he was planning on dumping it.

In theory also, Roberto Mello was going to come back a year ago and 
re-build the function repository, but he never did.

So let's use whatever we can get up quickly.  If we're going to use a 
wiki for this, though, can it be a separate wiki from 
wiki.postgresql.org?  If I'm searching for a specific function, I don't 
want to hit dozens of pages about database conversion and commitfests.

--Josh


Re: Code snippet hosting?

From
Greg Smith
Date:
On Fri, 20 Mar 2009, Brendan Jurd wrote:

> So, anybody got a useful code snippet they would like to volunteer as
> a first test subject?

The snippet I use the most is already on the Wiki in the admin section:
http://wiki.postgresql.org/wiki/Disk_Usage

I was recently poking at the now defunct PostgreSQL CookBook: 
http://web.archive.org/web/20031207045017/http://www.brasileiro.net/postgres/cookbook/

Two problems with grabbing a bunch of those:  the licensing is unclear for 
code submissions to that old site, and not everything will still work 
against a current release.

But it does suggest some useful categorization for organizing a collection 
of snippets.

--
* Greg Smith gsmith@gregsmith.com http://www.gregsmith.com Baltimore, MD


Re: Code snippet hosting?

From
"Joshua D. Drake"
Date:
On Thu, 2009-03-19 at 10:04 -0700, Josh Berkus wrote:

> So let's use whatever we can get up quickly.  If we're going to use a 
> wiki for this, though, can it be a separate wiki from 
> wiki.postgresql.org?  If I'm searching for a specific function, I don't 
> want to hit dozens of pages about database conversion and commitfests.

I disagree. I think we should keep it under the main wiki. Just create a
new section.

Joshua D. Drake


> 
> --Josh
> 
-- 
PostgreSQL - XMPP: jdrake@jabber.postgresql.org  Consulting, Development, Support, Training  503-667-4564 -
http://www.commandprompt.com/ The PostgreSQL Company, serving since 1997
 



Re: Code snippet hosting?

From
"Greg Sabino Mullane"
Date:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160


> So let's use whatever we can get up quickly.  If we're going to use a
> wiki for this, though, can it be a separate wiki from
> wiki.postgresql.org?

Ugh, please no. We have too many domains and sites as it is: we should
be moving towards consolidation, not expansion.

If the wiki needs something to get the code snippets looking nice, etc.,
let me know, I've gotten pretty handy with MediaWiki lately. Speaking
of which, we should upgrade the wiki to a recent stable version (and upgrade
the PG backend as well)

- --
Greg Sabino Mullane greg@turnstep.com
PGP Key: 0x14964AC8 200903191449
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
-----BEGIN PGP SIGNATURE-----

iEYEAREDAAYFAknClC4ACgkQvJuQZxSWSsi+iwCg1c2K4HXMSZC9lfWJQ46ftA/S
O2sAn1qY+rbGXjHKQdrg700L5RkPPVCR
=C/jH
-----END PGP SIGNATURE-----




Re: Code snippet hosting?

From
Selena Deckelmann
Date:


On Thu, Mar 19, 2009 at 11:51 AM, Greg Sabino Mullane <greg@turnstep.com> wrote:

> So let's use whatever we can get up quickly.  If we're going to use a
> wiki for this, though, can it be a separate wiki from
> wiki.postgresql.org?

Ugh, please no. We have too many domains and sites as it is: we should
be moving towards consolidation, not expansion.

+1
 
A nice format, with an easily distinguishable tag would be sweet.  Then we could publish a feed of the changes, and let people re-mix/re-format as they'd like.

Greg - could you make something based on the 'show highlighted code' example? That included a section for tags, and a description?

i.e. http://forge.mysql.com/tools/tool.php?id=85


If the wiki needs something to get the code snippets looking nice, etc.,
let me know, I've gotten pretty handy with MediaWiki lately. Speaking
of which, we should upgrade the wiki to a recent stable version (and upgrade
the PG backend as well)

+10 (I'm not volunteering to do it, however.)

-selena

--
Selena Deckelmann
Open Source Bridge - http://www.opensourcebridge.org
PDXPUG - http://pugs.postgresql.org/pdx
Me - http://www.chesnok.com/daily

Re: Code snippet hosting?

From
Alvaro Herrera
Date:
Selena Deckelmann escribió:

> Greg - could you make something based on the 'show highlighted code'
> example? That included a section for tags, and a description?
> 
> i.e. http://forge.mysql.com/tools/tool.php?id=85

This should be just a matter of installing a syntax highlighter
mediawiki extension, like enscript, GeSHi or ASHighlight

http://www.mediawiki.org/wiki/Extension:Enscript
http://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi
http://www.mediawiki.org/wiki/Extension:ASHighlight

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


Re: Code snippet hosting?

From
Peter Eisentraut
Date:
On Thursday 19 March 2009 17:45:00 Alvaro Herrera wrote:
> Brendan Jurd escribió:
> > So, anybody got a useful code snippet they would like to volunteer as
> > a first test subject? =)  Failing that, we could write up the
> > Mandelbrot recursive query demo.
>
> I support the Mandelbrot query as the first snippet :-)

Alright:

http://wiki.postgresql.org/wiki/Snippets
http://wiki.postgresql.org/wiki/Snippets/Mandelbrot_set

Now someone install all the plugins to do the syntax highlighting on the
subpage and produce some kind of recently-added or most-often-viewed index on
the superpage.

Or scrap it if you have a better idea. ;-)


Re: Code snippet hosting?

From
Josh Berkus
Date:
On 3/19/09 10:30 AM, Joshua D. Drake wrote:
> On Thu, 2009-03-19 at 10:04 -0700, Josh Berkus wrote:
>
>> So let's use whatever we can get up quickly.  If we're going to use a
>> wiki for this, though, can it be a separate wiki from
>> wiki.postgresql.org?  If I'm searching for a specific function, I don't
>> want to hit dozens of pages about database conversion and commitfests.
>
> I disagree. I think we should keep it under the main wiki. Just create a
> new section.

Can you search just a section?

--Josh



Re: Code snippet hosting?

From
Alvaro Herrera
Date:
Peter Eisentraut escribió:

> Alright:
> 
> http://wiki.postgresql.org/wiki/Snippets
> http://wiki.postgresql.org/wiki/Snippets/Mandelbrot_set
> 
> Now someone install all the plugins to do the syntax highlighting on the 
> subpage and produce some kind of recently-added or most-often-viewed index on 
> the superpage.

Okay, Stefan was kind enough to install the syntax highlighter
extension.  I gave it a try and it seems to work great -- thanks, Stefan.

I don't know how to create an index of subpages in the superpage, but I
added category tags so you can see the snippet index here:
http://wiki.postgresql.org/wiki/Category:Snippets

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


Re: Code snippet hosting?

From
Brendan Jurd
Date:
On Fri, Mar 20, 2009 at 7:45 AM, Alvaro Herrera
<alvherre@commandprompt.com> wrote:
> Peter Eisentraut escribió:
>
>> Alright:
>>
>> http://wiki.postgresql.org/wiki/Snippets
>> http://wiki.postgresql.org/wiki/Snippets/Mandelbrot_set
>>
> Okay, Stefan was kind enough to install the syntax highlighter
> extension.  I gave it a try and it seems to work great -- thanks, Stefan.

Nice.  It does a good job of highlighting the SQL.

I took the liberty of adding the results of the Mandelbrot query to
the page while I was there =)

We could also make a template for a snippet "infobox" that appears
floated to one side and shows some pertinent attributes of the
snippet, such as what language it's in and which version of Postgres
it works with, any dependencies, etc.

>
> I don't know how to create an index of subpages in the superpage, but I
> added category tags so you can see the snippet index here:
> http://wiki.postgresql.org/wiki/Category:Snippets

Probably relying on the category index is the right way to go ... the
superpage could just give an intro explaining what snippets are, and
maybe how to go about adding them, and link to the category page.

Cheers,
BJ


Re: Code snippet hosting?

From
Alvaro Herrera
Date:
Brendan Jurd escribió:
> On Fri, Mar 20, 2009 at 7:45 AM, Alvaro Herrera
> <alvherre@commandprompt.com> wrote:

> We could also make a template for a snippet "infobox" that appears
> floated to one side and shows some pertinent attributes of the
> snippet, such as what language it's in and which version of Postgres
> it works with, any dependencies, etc.

+1 to that too!

(Note that I added a category tag for the language too.)

> > I don't know how to create an index of subpages in the superpage, but I
> > added category tags so you can see the snippet index here:
> > http://wiki.postgresql.org/wiki/Category:Snippets
> 
> Probably relying on the category index is the right way to go ... the
> superpage could just give an intro explaining what snippets are, and
> maybe how to go about adding them, and link to the category page.

Sounds good.

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


Re: Code snippet hosting?

From
Peter Eisentraut
Date:
Alvaro Herrera wrote:
> Peter Eisentraut escribió:
> 
>> Alright:
>>
>> http://wiki.postgresql.org/wiki/Snippets
>> http://wiki.postgresql.org/wiki/Snippets/Mandelbrot_set
>>
>> Now someone install all the plugins to do the syntax highlighting on the 
>> subpage and produce some kind of recently-added or most-often-viewed index on 
>> the superpage.
> 
> Okay, Stefan was kind enough to install the syntax highlighter
> extension.  I gave it a try and it seems to work great -- thanks, Stefan.
> 
> I don't know how to create an index of subpages in the superpage, but I
> added category tags so you can see the snippet index here:
> http://wiki.postgresql.org/wiki/Category:Snippets

Maybe the subpages approach isn't so great then, because the 
alphabetical index in the category listing puts everything under "S" now.

I suggest that we keep /Snippets as a kind of info and index page, but 
move the rest to the top level and rely on the category tag exlusively.


Re: Code snippet hosting?

From
Brendan Jurd
Date:
On Fri, Mar 20, 2009 at 7:19 PM, Peter Eisentraut <peter_e@gmx.net> wrote:
> Maybe the subpages approach isn't so great then, because the alphabetical
> index in the category listing puts everything under "S" now.
>
> I suggest that we keep /Snippets as a kind of info and index page, but move
> the rest to the top level and rely on the category tag exlusively.
>

+1


Re: Code snippet hosting?

From
Alvaro Herrera
Date:
Brendan Jurd escribió:
> On Fri, Mar 20, 2009 at 7:19 PM, Peter Eisentraut <peter_e@gmx.net> wrote:
> > Maybe the subpages approach isn't so great then, because the alphabetical
> > index in the category listing puts everything under "S" now.
> >
> > I suggest that we keep /Snippets as a kind of info and index page, but move
> > the rest to the top level and rely on the category tag exlusively.
> 
> +1

Done.

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


Re: Code snippet hosting?

From
David Fetter
Date:
On Fri, Mar 20, 2009 at 10:30:12AM -0400, Alvaro Herrera wrote:
> Brendan Jurd escribió:
> > On Fri, Mar 20, 2009 at 7:19 PM, Peter Eisentraut <peter_e@gmx.net> wrote:
> > > Maybe the subpages approach isn't so great then, because the
> > > alphabetical index in the category listing puts everything under
> > > "S" now.
> > >
> > > I suggest that we keep /Snippets as a kind of info and index
> > > page, but move the rest to the top level and rely on the
> > > category tag exlusively.
> > 
> > +1
> 
> Done.

How do we add language categories?

Cheers,
David.
-- 
David Fetter <david@fetter.org> http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter      XMPP: david.fetter@gmail.com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate


Re: Code snippet hosting?

From
Alvaro Herrera
Date:
David Fetter escribió:

> How do we add language categories?

I just added some instructions in the snippets talk page.

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


Re: Code snippet hosting?

From
David Fetter
Date:
On Sat, Mar 21, 2009 at 06:21:56PM -0400, Alvaro Herrera wrote:
> David Fetter escribió:
> 
> > How do we add language categories?
> 
> I just added some instructions in the snippets talk page.

Thanks :)

Cheers,
David.
-- 
David Fetter <david@fetter.org> http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter      XMPP: david.fetter@gmail.com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate