Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

eric256's scratchpad

by eric256 (Parson)
on Jun 01, 2004 at 15:33 UTC ( #358133=scratchpad: print w/ replies, xml ) Need Help??

The code:
sub form_create : Local { my ($self, $c) = @_; $c->stash->{authors} = [$c->model('DB::Authors')->all]; $c->stash->{template} = 'books/form_create.tt2'; } =head2 list Fetch all book objects and pass to books/list.tt2 in stash to be displ +ayed =cut sub list : Local { # Retrieve the usual Perl OO '$self' for this object. $c is th +e Catalyst # 'Context' that's used to 'glue together' the various compone +nts # that make up the application my ($self, $c) = @_; # Retrieve all of the book records as book model objects and s +tore in the # stash where they can be accessed by the TT template $c->stash->{books} = [$c->model('DB::Books')->all]; # Set the TT template to use. You will almost always want to +do this # in your action methods (action methods respond to user input + in # your controllers). $c->stash->{template} = 'books/list.tt2'; }
Code for list.tt2
[%- # optional, but both the beginning and the ending TT tags supp +ort chomping. -%] [% # Provide a title to root/lib/site/header -%] [% META title = 'Book List' -%] <table> <tr><th>Title</th><th>Rating</th><th>Author(s)</th></tr> [% # Display each book in a table row %] [% FOREACH book IN books -%] <tr> <td>[% book.title %]</td> <td>[% book.rating %]</td> <td> [% tt_authors = []; tt_authors.push(author.last_name) FOREACH author IN bo +ok.authors -%] [% tt_authors.join(", ") | html %] ([% tt_authors.size | +html %]) </tr> [% END -%] </table> ~
[% META title = 'Manual Form Book Create' -%] [% Dumper.dump(authors) %] <form method="post" action="[% c.uri_for('form_create_do') %]"> <table> <tr><td>Title:</td><td><input type="text" name="title"></td></tr +> <tr><td>Rating:</td><td><input type="text" name="rating"></td></ +tr> <tr><td>Author ID:</td><td><input type="text" name="author_id">< +/td></tr> </table> <input type="submit" name="Submit" value="Submit"> </form> [% # Try out the TT Dumper (for development only!) -%] <pre> Dump of the 'authors' variable: </pre>

wst
use strict; use warnings; my @data = qw/123456 abcde 10-MAY-2006/; print type($_), "\n" for @data; sub type { local $_ = shift; return 'date' if /\d\d-\D\D\D-\d\d\d\d/; return 'number' if /^\d+$/; return 'string'; }
erix
create or replace type body string_agg_type is static function ODCIAggregateInitialize(sctx IN OUT string_agg_type +) return number is begin sctx := string_agg_type( null, 0 ); return ODCIConst.Success; end; member function ODCIAggregateIterate(self IN OUT string_agg_type, value IN varchar ) return number is begin self.total := self.total || ','; if (self.item_count > 5) THEN self.total := self.total || chr(13); self.item_count := 0; end if; self.item_count := self.item_count + 1; self.total := self.total || value; return ODCIConst.Success; end; member function ODCIAggregateTerminate(self IN string_agg_type, returnValue OUT clob, flags IN number) return number is begin returnValue := ltrim(self.total,','); return ODCIConst.Success; end; member function ODCIAggregateMerge(self IN OUT string_agg_type, ctx2 IN string_agg_type) return number is begin self.total := self.total || ctx2.total; return ODCIConst.Success; end; end; create or replace FUNCTION stragg(input varchar2 ) RETURN clob PARALLEL_ENABLE AGGREGATE USING string_agg_type;
Hacker:
my $p = $cgi->param("pl_copyright") || 'no'; my $p_values = { 'yes' => '--yes', 'no' => '--no' }; my $p_cmd = exists $p_values->{$p} ? $p_values->{$p} : '--no';
LaTex:
\documentclass[letterpaper,10pt,oneside]{book} \pagestyle{headings} \setlength{\oddsidemargin}{0in} \setlength{\evensidemargin}{0in} \begin{document} \section{Base Page} \subsection*{Page Info} \textbf{Title:} Base Page \\ \textbf{Page\_ID:} 0 \\ \textbf{Last Updated:} 2007-09-20 \\ \textbf{Last By:} EJH\_ADMIN \\ \textbf{Comments:} This base page holds all common navigations items. Search, home, logo +ut and jump box. \subsection*{Branches} \begin{tabular}{|c|c|c|c|} \hline Sequence & Branch Point & Branch Type & When \\ \hline 10 & AFTER\_PROCESSING & Branch to Page or URL & LOGOUT \\ \hline 10 & AFTER\_PROCESSING & Branch to Page or URL & MOVE \\ \hline \end{tabular} \subsection*{Regions} \subsubsection{Region: Breadcrumb } \begin{tabular}{|l|l|} \hline Sequence & 1 \\ \hline Template & Breadcrumb Region \\ \hline Column & 1 \\ \hline Position & Page Template Region Position 1 \\ \hline Source Type & Breadcrumb \\ \hline \end{tabular} \paragraph{Items} \begin{tabular}{|l|l|l|} \hline Sequence & Name & Type \\ \hline \hline 30 & P4\_PARENT\_NAME & Hidden \\ \hline Source Type & \multicolumn{2}{|l|}{SQL Query} \\ \hline \hline 40 & P4\_PARENT\_ID & Hidden \\ \hline Source Type & \multicolumn{2}{|l|}{SQL Query} \\ \hline \end{tabular} \paragraph{Buttons} \begin{tabular}{|l|l|l|l|} \hline Sequence & Name & Label & Position \\ \hline \hline 30 & BACK & Back to \&P4\_PARENT\_NAME. & BOTTOM \\ \hline \textbf{Redirect URL} & \multicolumn{3}{|l|}{f?p=\&APP\_ID.:4:\&SESSION.::\&DEBUG.:4:P4\_CATEG +ORY\_ID:\&P4\_PARENT\_ID.} \\ \hline \end{tabular} \end{document}
Oracle SQL for newest reply in thread:
select topic.id, ( SELECT id reply_id FROM ( SELECT rownum r , replies.* FROM nf_posts replies start with parent_id = topic.id connect by parent_id = PRIOR id ORDER BY UPDATED_DATE DESC ) WHERE r = 1 ) from nf_posts topic where parent_id is null
Broadcaster:
#!/usr/bin/perl use strict; use warnings; use IO::Socket::INET; my $port = 9870; print "Broadcasting on UDP port: $port To: ", inet_ntoa(INADDR_BROADCA +ST), "\n"; my $sock = IO::Socket::INET->new(PeerPort => $port, PeerAddr => inet_ntoa(INADDR_BROADCA +ST), #PeerAddr => '192.168.12.255', Proto => 'udp', LocalAddr => 'localhost', Broadcast => 1 ) or die "Can't bind : $@\n"; # 10 udp's on the wire for (my $i=0;$i < 100;$i++) { my $data = 'UDP packet ' . $i; # send udp packet print "Sending '$data'\n"; $sock->send($data); sleep (rand 5); }
Client:
use strict; use warnings; use IO::Socket::INET; $|++; my $port = 9870; print "Listening on UDP port: $port\n"; my $sock = IO::Socket::INET->new( Proto => 'udp', LocalPort => $port, Broadcast => 1 ) or die "Can't bind : $@\n"; my $mess; while ($sock -> recv ($mess, 2048)) { print "Saw: \n$mess\n"; }
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (10)
As of 2014-09-02 16:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (25 votes), past polls