KBD

Keith Devens .com

Monday, October 13, 2008 Flag waving
Don't panic. – Douglas Adams (The Hitchhiker's Guide to the Galaxy)

Archive: August 17, 2005

← August 16, 2005August 18, 2005 →

Daily link icon Wednesday, August 17, 2005

  1. SitePoint Forums - What happened to Object Aggregation? (in PHP). "Well, here is basically what I came up to dynamically bind methods from various classes together at runtime, in both PHP 4 and PHP 5. (OO is PHP 4 style)."

       (0) Tags: [Programming]

Java join function

Because Java is too much of a pain in the ass to have included one in the standard library, here's a simple string join function:

public static String join(String[] pieces){
    return join(pieces, " ");
}
public static String join(String[] pieces, char sep){
    return join(pieces, String.valueOf(sep));
}
public static String join(String[] pieces, String sep){
    if(pieces.length == 0) return "";

    StringBuffer buf = new StringBuffer();
    buf.append(pieces[0]);
    for(int i=1,n=pieces.length; i<n; i++)
        buf.append(sep).append(pieces[i]);
    return buf.toString();
}

Update: Of course, there's also a join function in org.apache.commons.lang.StringUtils.

  1. Join Java "is a programming language that extends the standard Java programming language with the Join Semantics of the Join Calculus". Ooh. Here's the main website.

       (0) Tags: [Programming]

Heredoc syntax

Because I always forget...

Perl heredoc syntax:

$_ = <<EOF;
text goes here
EOF

PHP heredoc syntax:

<?php
$str 
= <<<EOF
text goes here
EOF;
?>

Ruby heredoc syntax:

str = <<EOF
text goes here
EOF

Of course, Python's heredoc syntax is easy to remember:

str = """text goes here
"""

(text is on the same line as the """ for parity with the other examples)

  1. magpiebrain - A comparison of Django with Rails (to read), via Simon. Also see How Django processes a request.

       (0) Tags: [Programming]
  2. The Island was basically a remake of Logan's Run. But with more explosions and highly improbable action scenes. Cool premise, but of course it wasn't their idea anyway.

       (0) Tags: [TV/Movies]
← August 16, 2005August 18, 2005 →
October 2008
SunMonTueWedThuFriSat
 1234
567891011
12131415161718
19202122232425
262728293031 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 7 posts

Recent comments XML

new⇒Spider solitaire

I have now won, at the "Difficult"​level, 186 games of Spider​Solitaire.  I...

75.179.28.113: Oct 13, 9:34am

new⇒Girls, please don't get breast implants

Please, don't marry him.

You​want to get surgery to make​yourself more i...

gigi: Oct 12, 11:47pm

I hate PHP

Elliot Anderson,

Dude!! You the​man! The reverse replacement for​array_u...

Alex Ndungu: Oct 11, 1:35am

Call a function from a string in Python

?!code:
some_object.__getattribute​__('method_name')()
?!/code

is​the s...

Patrick Corcoran: Oct 8, 3:53pm

Sed one-liners

Hi.

I wanted to let you know​that I wrote an article "Famous Sed​One-Lin...

Peteris Krumins: Oct 8, 3:05am

Timesheet Calculator

Hadn't seen it before now, but my​company already uses a time​tracking prog...

Keith: Oct 7, 10:44am

Generated in about 0.076s.

(Used 7 db queries)

mobile phone