text:
Write the longest sentence using keywords of a programming language
As the title said, the challenge is to write the longest sentence by only using the keywords of 1 programming language.
For instance, using the keywords of C++, it is possible to write this sentence:

do not try this float

What can you come up with?

Shakespeare should be good for this http://en.wikipedia.org/wiki/Shakespeare_(programming_language)#List_of_reserved_words

Are repetitions allowed?

@elssar Yes, so long as you don't abuse them along the lines of http://en.wikipedia.org/wiki/Buffalo_buffalo_Buffalo_buffalo_buffalo_buffalo_Buffalo_buffalo.

Is the score the total number of words, or just unique words?

@Sir_Lagsalot Total number.

I liked the answers! They are damn funny!

You don't need many words to make arbitrarily long sentences. For example, with the C++ keywords you can do "Try this and try this and...".  You can famously make an arbitrarily long sentence using only the word "buffalo", and as someone says on this page, you can do the same thing with "char" ("it's not too hard to see fishes of the genus Salvelinus scorching each other, given access to sufficiently powerful flamethrowers"). Maybe it would be more interesting if each word could only be used once?

I'd like to see some corpus tested with keyword lists in various languages, and see what the longest strings of consecutive keywords are in literature.

This is now my favorite question on this site.

I was doing this before this question was posted. I was being quite immature at the time, so I'll warn you about explicit language. http://chat.stackoverflow.com/transcript/7?m=4671602#4671602

Finally a challenge that the APL guys can't win

Code challenges must be answerable with code.

Mathematica  100 80 unique words
Here's a start.  All standard words in Mathematica begin with upper case.
this includes I, the square root of negative 1.
On Sunday, And For All Times-- Assuming, On Opening Clear Dynamic Interactive Notebooks For Setting Contours,  I Do Not Translate  Missing Blue Arrays Which Span Temporary, Asynchronous, And Invisible Characters, Nor Do I Remove Undefined Arrowheads With Editable And Sound Outer Orange Roots Which Magnify Shallow Names Together With False Attributes (Because Most Axes Split Full Inner Kernels In Reverse Order)-- And While I Animate Undefined Quiet Ticks, I Begin With  Tolerance And Operate On All Manual Matrices, Interleaving Circle With Cylinder, Boxed Skeleton With Compiled Cuboid, Red Cross With Nearest Timing Pattern,
And Join Repeated Unique White Links With Heads ...

In case anyone is interested, here are 500+ words recognized by Mathematica (no additional libraries required). They are not all keywords, but experienced Mathematica programers will know and have used just about all of them.

{Abort, Above, Abs, Accumulate, Accuracy, AddTo, After, Alignment,
All, Alternatives, Analytic, And, Animate, Animator, Annotation,
Annuity, Antialiasing, Antisymmetric, Apart, Appearance, Append,
Apply, Array, Arrays, Arrow, Arrowheads, Assert, Assuming,
Assumptions, Asynchronous, Attributes, Automatic, Axes, Axis, Back,
Background, Backslash, Backward, Band, Baseline, Because, Beep,
Before, Begin, Below, Binarize, Binomial, Blank, Blend, Block, Blur,
Bookmarks, Booleans, Bottom, Bounds, Boxed, Break, Button, Byte,
Cancel, Cap, Cases, Cashflow, Catch, Ceiling, Cell, Cells, Censoring,
Center, Character, Characters, Check, Checkbox, Chop, Circle, Clear,
Clip, Clock, Close, Closed, Closing, Coarse, Coefficient, Collect,
Colon, Colorize, Column, Commonest, Compile, Compiled, Complement,
Complex, Compose, Composition, Compress, Condition, Cone, Congruent,
Conjunction, Connect, Constant, Constants, Context, Contexts,
Continue, Contours, Control, Convergents, Convolve, Copyable,
Correlation, Cot, Count, Covariance, Cross, Cumulant, Cup, Curl,
Cycles, Cylinder, Darker, Date, Debug, Decrement, Default, Defer,
[Degree], Deinitialization, Deletable, Delimiter, Delimiters,
Denominator, Deploy, Deployed, Depth, Derivative, Diagonal, Dialog,
Diamond, Differences, Dilation, Dimensions, Direction, Directive,
Disjunction, Disk, Dispatch, Display, Distribute, Distributed,
Dithering, Divide, Dividers, Divisible, Divisors, Do, Dot, Down,
Drop, Dynamic, Editable, Eigenvalues, Element, Eliminate, Empty,
Enabled, Encode, End, Enter, Epilog, Equal, Equivalent, Evaluator,
Except, Exists, Exit, Expand, Expectation, Exponent, Export,
Expression, Extract, Factor, Factorial, Fail, False, File, Filling,
Find, First, Fit, Flat, Flatten, Floor, Fold, Font, For, Forward,
Frame, Front, Full, Function, Gather, General, Generic, Get, Graph,
Graphics, Greater, Grid, Hash, Head, Heads, Histogram, Hold, Hue,
Hyperlink, Hyphenation, I, Identity, If, Image, Implies, In,
Increment, Inherited, Inner, Input, Insert, Inset, Install, Integer,
Integers, Integral, Integrate, Interactive, Interleaving, Interval,
Invisible, Item, Join, Joined, Kernels, Label, Labeled, Large,
Larger, Last, Latitude, Launch, Left, Legended, Length, Less, Level,
Lighting, Limit, Line, Links, List, Listable, Listen, Literal,
Locked, Log, Longest, Longitude, Magnification, Magnify, Majority,
Manipulate, Manual, Map, Masking, Material, Matrices, Maximize, Mean,
Median, Medium, Menu, Mesh, Message, Messages, Method, Minimize,
Minors, Missing, Modal, Mode, Modular, Module, Modulus, Moment,
Monday, Monitor, Most, Mouseover, Multinomial, Multiplicity,
Multiselection, Names, Nearest, Needs, Negative, Nest, Next, None,
Nor, Norm, Normal, Normalize, Not, Notebook, Notebooks, Null, Number,
Numerator, Off, Offset, On, Opacity, Open, Opening, Operate,
Optional, Options, Or, Order, Ordering, Orderless, Orthogonalize,
Out, Outer, Over, Overflow, Paclet, Pane, Panel, Paneled,
Parallelize, Parameter, Parenthesize, Part, Partition, Paste, Path,
Pattern, Pause, Permutations, Permute, Perpendicular, [Pi],
Piecewise, Pivoting, Placed, Placeholder, Plain, Play, Plot, Plus,
Point, Polygon, Polynomials, Position, Positive, Power, Precedence,
Precedes, Precision, Prefix, Prepend, Previous, Print, Probability,
Projection, Prolog, Properties, Property, Proportion, Protect,
Protected, Pruning, Put, Pyramid, Quantile, Quantity, Quartics,
Quartiles, Queueing, Quiet, Quit, Quotient, Radon, Random, Range, Raster, Rasterize, Rational, Rationals, Read, Real, Reap, Record,
Rectangle, Reduce, Refine, Refresh, Reinstall, Release, Remove,
Removed, Repeated, Replace, Resampling, Rescale, Residue, Resolve,
Rest, Return, Reverse, Riffle, Right, Root, Roots, Rotate, Round,
Row, Rule, Saturday, Save, Saveable, Scale, Scaled, Scan, Scrollbars,
Select, Selection, Sequence, Series, Set, Setbacks, Setter, Setting,
Shading, Shallow, Share, Sharpen, Short, Show, Sidebar, Sign,
Signature, Simplify, Skeleton, Skip, Slot, Smaller, Socket, Solve,
Sound, Sow, Spacer, Spacings, Span, Speak, Sphere, Splice, Split,
Square, Stack, Star, Streams, String, Stub, Subfactorial, Subgraph,
Subscripted, Subset, Subtract, Sum, Superset, Surd, Syntax, Table,
Take, Tally, Temporary, Text, Texture, Therefore, Thread, Threshold,
Through, Ticks, Times, Timing, Together, Toggle, Toggler, Tolerance,
Tooltip, Top, Total, Trace, Tracers, Translate, Transpose, True,
Tube, Tuples, Undefined, Underlined, Underscript, Unequal, Uninstall,
Union, Unique, Unitize, Unset, Up, Variables, Vertical, Wedge,
Weights, Which, While, Whitespace, With, Word, Write}

Suddenly, I think Mathematica has too many keywords.

You may have a point. In Mathematica, everything is an expression and all symbols, such as the times-sign, are names when expressed in full, i.e.. long form, e.g. Times. I found 332 common English words in Mathematica. This does not include compound words such as AppendTo nor names of functions, of which there are literally thousands (but they are not really English words).

332 was the count a few hours ago. I checked, and there are well over 500 English words acceptable for using in Mathematica programs.

@dude Many Option and Color names aren't in your list ... you could add up another 300, I guess :)

Aren't most of these identifiers, not keywords?

@Geoff The breakdown of 57 words beginning with A or B is this.  26 Predicates, of which 24 take arguments: (Abort, Abs, Accumulate, Accuracy, AddTo, Animator, Animate, Annotation, Annuity, Apart, Append, Apply, Array, Arrow, Assert, Attributes, Band,Beep, Begin, Binarize, Binomial, Blend, Blur, Break,Button);
16 Settings and options: (Above, Alignment, Antialiasing, Antisymmetric, Arrowheads, Appearance, Asynchronous, Automatic, Axes, Axis, Background,
Back, Backward, Baseline, Bookmarks, Boxed, Bottom);

4 logical operators: (All, And, Alternatives, Assuming);
6 frontend tokens for formatting: (Analytic, Bounds, Above, Before,Below, After);
5 Identifiers, Delimiters, and Undefined Symbols: (Arrays, Because, Blank, Byte, Backslash, Block, Booleans).  The word "Bra" was included due to a mistake on my part.

C++, 25 unique words, 28 total

True friend, do goto register for this new short public class for
  private auto operator (while inline, return this signed template),
  else break & void this long volatile union.

You can use and instead of &. :)

@rightfold I considered it, but I felt counting alternate identifiers would make it too easy, and not all tools recognize them as keywords.

While making sentences is not really my strong suite, here goes nothing -
Python 20 words

Finally, continue with import and raise global yield while class lambda is in break and try and print exec pass.

To help with checking, I wrote some code to check whether the words are in the keyword list or not.
from keyword import kwlist
from re import findall

def kwcheck(sentence):
    """Check whether all the words of a sentence are Python keywords"""
    words= findall(r'\w+', sentence)
    for word in words:
        if word.lower() not in kwlist:
            return False
    return True, len(words)

if __name__ == '__main__':
    sen= raw_input("Enter your sentence: ")
    print kwcheck(sen)

The Importance of Education
-- by A. Coder Guy (written in Python)
Continue class, except if class is not for you.
With no class, raise and assert!  Or yield, pass,
and break.  Try and continue!  Or - finally - return from class.

Since when is you a Python keyword?

ha, good catch.  Not sure how I can modify it; but feel free to downvote :-)

Is not for self maybe? It's not quite standard usage, but I think it'd be understandable.

Common Lisp
:In :Common :Lisp :a :keyword :is :simply :a :symbol :which :has :the :KEYWORD :home :package :which :is :true :of :all :symbols :starting :with :a :colon :so :you :can :construct :arbitrarily :long :sentences. :Do :I :win?

This, for example:
(every #'keywordp '(:In :Common :Lisp :a :keyword :is :simply :a :symbol :which :has :the :KEYWORD :home :package :which :is :true :of :all :symbols :starting :with :a :colon :so :you :can :construct :arbitrarily :long :sentences. :Do :I :win?))

Evaluates to T
See http://www.lispworks.com/documentation/HyperSpec/Body/26_glo_k.htm

c#, 17 words
This looks like pretty reasonable technical mumbo-jumbo.
I guess it can be extended a bit.
foreach is a bit stretching the rules.
Used this keyword list.

Try explicit operator, in case implicit string foreach virtual struct is as unsafe as this volatile lock.

Factor - 109

"Take my-world and with happy? make items to-do. Pause. Self
  not happy?"
"Yes<<."
"From oldies?"
"Yes>>. Self sad."
"Haversin, listen, each and every formula become oldies. Become not
  sad, do-something greater-from-last. Or .
  My-arch self is_gold<<. Change-is_gold. Go-back where
  your_event_mask<< make happy? future. Fulfill promise of
  self. Remember-definition, light are-copies-of happy?"
"Sweetest-day near>> me?. Handle-me, handle-me. Sad self.
  Home not near>>. Home not near>> at all. Out-of-memory.
  Sad self, old<< self. Most near>> ones left self long
  ago."
"Haversin, change-known self. No sad, Haversin.
  Become happy? Forget what<< keep self from happy?
  My-arch self want>> self be> not sad. Before leave,
  remember-error."
"Not remember-error! Error not! My-array
  has-entry? not of error! Leave error!"
"Smart-if remember-error."

A lot of these are stretches, but it somewhat tells a story, so it makes up for that.

1 + for Factor!!

Factor's especially good for this because it has no keywords :D

Applescript, 30 words
I never thought I would post an Applescript answer on PPCG, but given Applescript's natural language design philosophy, it is perfectly suited for this question.
I'm not much of a wordsmith, so here's one just to get us started, but I fully expect others will easily beat this:
Beneath the eighth error, my third script is ignoring the sixth local copy
of the fourth transaction to the seventh property whose reference is given
to repeat every tenth second.

This is constructed just from Applescript's keywords, which are:
Keywords

about above after against and "apart from" around as "aside from" at back before beginning behind below beneath beside between but by considering contain contains continue copy div does eighth else end equal equals error every exit FALSE fifth first for fourth from front get given global if ignoring in "instead of" into is it its last local me middle mod my ninth not of on onto or "out" of over prop property put ref reference repeat return returning script second set seventh since sixth some tell tenth that the then third through thru timeout times to transaction TRUE try until use where while whose with without

The following may or may not be considered valid for this challenge:
Built-in classes and properties

alias application boolean centimetres centimeters character class contents constant "cubic centimetres" "cubic centimeters" "cubic feet" "cubic inches" "cubic metres" "cubic meters" "cubic yards" date "date string" day "degrees Celsius" "degrees Fahrenheit" "degrees Kelvin" feet file frontmost gallons grams id inches integer item kilograms kilometres kilometers length list litres liters metres meters miles month name number ounces paragraph "POSIX file" "POSIX path" pounds quarts "quoted form" real record reference rest reverse "RGB color" running script "square feet" "square kilometres" "square kilometers" "square metres" "square meters" "square miles" "square yards" text time "time string" "unit types" version weekday word yards year

Built-in Commands

activate "ASCII character" "ASCII number" beep "choose application" "choose color" "choose file" "choose file name" "choose folder" "choose from list" "choose remote application" "choose URL" "clipboard info" "close access" copy count "current date" delay "display alert" "display dialog" "display notification" "do shell script" get "get eof" "get volume settings" "info for" launch "list disks" "list folder" "load script" "localized string" log "mount volume" offset "open for access" "open location" "path to" "path to resource" "random number" read round run "run script" say "scripting components" set "set eof" "set the clipboard to" "set volume" "store script" summarize "system attribute" "system info" "the clipboard" "time to GMT" write

Considering/Ignoring attributes

case diacriticals hyphens "numeric strings" punctuation "white space"

Shakespeare
44 words, 28 unique
Yes, all of these words really have keyword-level significance in Shakespeare. Shakespeare character names, normal nouns and adjectives are also a core part of the language, but I thought they'd bloat the list too much for this exercise.

You must listen to your heart to enter your mind: the heart shall
  recall the difference between the exit and the return, to let you
  remember you are your art, and so you are the product of yourself and
  an act better than yourself.

Ruby, 41 words

True self, do not begin class break, end class break, ensure class break, redo
  and redo class break, retry class break, rescue class break, or yield
  class break, until next class end (or next class module or next class
  return), or else!

That's just using words listed as actual keywords. There are a lot of other words that act like keywords because they're methods of the kernel or instance methods of Class.
A cheesier approach would start

Do not def "alias","begin","break",...

C++.
A lot of repeated words, but a borderline sensible sentence:
If this volatile friend false and do return unsigned public union template throw union
template goto void for false friend not using class, and try switch for new protected
union using true friend, or else catch long, private break using this public operator
switch for explicit union using new virtual friend if union for this friend not long and
true.

Aka: If this moody girl won't sign the marriage license, throw away the license and find a nice new girl--and if that doesn't work out, just try a...virtual union over the "public operator switch".
Oh, as far as exact number of words goes, sorry but I'm too lazy to count.

Python, 48 words

class, try (if lambda is in class) and continue as if in break from
global import and raise yield for return from exec; else, while lambda
is not in class, continue with print import except for def, finally
pass 'assert elif' or else del is not for class.

This contains every keyword in keyword.kwlist
I think some explanation is required here: This sentence is said to a school class that is currently in some place called exec. In the class, there are amongst others two people named lambda and def. def should pass the assert elif test because otherwise the DEL (German ice hockey league) is nothing for the class.

 o.o

ECMA
A bit of broken English due to the fact that ECMA reserved words contain neither conjunctions nor more than one conjugation of verb. It's really an imperative language!

Do try this new typeof case, with this default catch function.
In this case, break in with this switch. If catch break, return with
this new switch; finally throw in with this new function.

Perl - several entries
when given tied package untie, unpack and unlink until open, redo each package (link, pack and bind or tie) or dump if not open; next, read map, write state, reverse and return system. (28 distinct words)
bless (not hex) my rand-y flock; continue until values accept no sin; study END times, accept sleep and die; CHECK keys and close each crypt lock. (25 distinct words)
tell our next caller: "use fork and pipe; push, break, delete, kill, and DESTROY."  (13 distinct words)

Haskell (~29-ish)

In case of foreign type, import data module; where as for all (forall) in qualified class, if hiding, then do default (let in, deriving instance of data family where qualified, otherwise data instance of type family); else type in fix (infix).

In Haskell, data family is a separate keyword from data, likewise with type family, and deriving instance is separate from deriving and instance. I am using forall as two words (counting only one), where as as one (counting two), and infix as two (counting one).


text:
Identify the compiler
The challenge
You are given a function compile(s: String): Integer which returns 0 if s could be compiled and anything other than 0 if it failed (the resulting code is not important).
The thing is that you don't know for what language the function is made for, so it is up to you to figure that out by giving the function small snippets of code and observing what it returns. The good part is that a team of scientists have tried before you and have narrowed down the list to C, C++, C#, Java and JavaScript (these are the only widespread languages which have similar syntax I could think of).
Rules

General code-golf rules apply.
There is no strict output format; as long as it's readable and understandable it's ok.
If these 5 languages are not enough for you then you can add your own favourites and you'll be rewarded with extra stars (★) (that do nothing).

Note1: the compiler is up to date with the latest standard of whatever language it's designed for.
Note2: I know JavaScript does not compile, but it goes though some parsing process; if it's valid JavaScript code then it passes

What are we to provide? The set of strings that can be used to tell the compilers apart, minimizing the total length of the strings?

@GeoffReedy I was looking just for the code to determine the language, but the explanations you provided are more than welcome

Total snippet length 8; test program 83 (C)
Distinguish JavaScript and C from C++, Java, and C#
a;

Distinguish JavaScript from C
0

Distinguish C++ from C# and Java
#

Distinguish C# and Java
[:a]

C code to determine the language
#define C(x)compile(#x)?
main(){puts(C(a;)C(#)C([:a])"J":"C#":"C+":C(0)"C":"JS");}

Snippets tested with
C: gcc 4.7.2 with -std=c99
C++: g++ 4.7.2 with -std=c++11
Java: javac 1.7.0_09
JavaScript: JavaScript-C 1.8.5
C#: Mono C# compiler version 2.10.8.0

#define C(x)compile(#x)? saves a space and lots of quotes.

@ugoren thanks, I actually thought I tried the stringification thing but it didn't work for some reason; I must have had some other problem too, cause it works fine now

But you somehow got it mixed up - C(#x) won't work.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Write the implementation to pass this test
Given the following test, implement an addOne function in C# so it passes, without any modification to the test. TIP: Yes, it is possible.
[TestMethod]
public void TheChallenge()
{
    int a = 1;

    addOne(a);

    Assert.IsTrue(a == 2);
}

EDIT: clarified the Assert to avoid confusion. The value of a should be 2; there's no trick there.

do you mean void addOne(ref int a){a++;}

That wouldn't compile. The ref keyword is not in the test (you would need addOne(ref a);).

Perhaps you could use reflection to somehow rewrite the IL for the test method to increment a after the return. That's all I can think of.

This isn't a very code golf friendly question.

@istepaniuk oh, I've never actually written any C#, so I googled and tried to understand the syntax for pass by reference.
MrZander: it isn't tagged code golf. It's awfully simple for puzzle though.

No need to rewrite IL on runtime. But it goes on those lines of nasty hack. TIP: unsafe code is allowed

@MrZander, @shiona; please tag accordingly, I'm new here.

Ummm, simply provide an implementation of AssertTrue that doesn't throw anything?
void addOne(int a){}

void AssertTrue(bool b) { }

You never specified what testing framework is used here. It looks like MSTest, but I fired up a new test project and AssertTrue doesn't exist, so I took the liberty of implementing it myself.
EDIT
This solution might be what you were fishing for:
void addOne(int x)
{
  unsafe
  {
    int* i = &x;
    i += 4;
    *i += 1;
  }
}

I feels pretty fragile, but it works on my box consistently. It probably depends heavily on the compiler, so hopefully it is reproducible elsewhere.

+1 for lateral thinking, but the question states "Implement an addOne function" I will clarify the Assert to make it pure mstest.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Merge working time periods
You have an array of working time period pairs (from, till) received from user input and written according  24-hour clock format convention.
   You have to merge these periods if the intersect each other.
For example, if you have (10, 12), (11, 13), (12, 14) you should merge them into (10,14).
   Also (23, 0) and (0, 1) should be merged into (23, 1).
UPDATE:
@dmckee Let assume that the set of pairs like (10:00, 12:00) is the valid input.
@dude We don't consider Sundays and holidays so all merges should be performed for the common twenty-four hours range.
@steven-rumbalski  The result of (0,8), (8,16), (16,0) may be any (x,x) pair, for example, (00:00,00:00).
Example 1
Input
(09:00,12:00),(11:00,13:00),(17:00,19:00)

Output
(09:00,13:00),(17:00,19:00)

Example 2
Input
(00:00,08:00),(08:00,16:00),(16:00,00:00)

Output
(00:00)

Is (10,12) a valid input, or should it be (10:00, 12:00) or something similar? Likewise, what is the correct format for the output? Also each challenge should specify what the metric is (i.e. we don't only do [code-golf] or even default to it).

Because one work shift can spill over from one day into the next [as (23,0)+(0,1) =(23,1) appears to show], shouldn't we be keeping track of the days in the workweek also?  If Sunday is not a work day, it would seem that (23,1), starting Sunday Evening and going to 1 am Monday, would not count.  However, from Monday to Tuesday, it would be counted.

What should the result of (0,8), (8,16), (16,0) be?

In the future, maybe post your spec to the sandbox on meta first to get feedback before you post. This could have been a great question with a little more work.

@TimSeguine thank you for your suggestion, I did not know about this opportunity!

Python (198 chars)
r=[]
p=r.append
l=r+sorted(a<b and (a,b)or p((0,b))or(a,24)for a,b in input())
r[:]=[]
a,b=l[0]
for c,d in l[1:]:
 if c>b:p((a,b));a,b=c,d
 elif b<d:b=d
if b>23:b=a and r.pop(0)[1]
p((a,b))
print r

Example:
> python merge.py
(10, 12), (11, 13), (12, 14)
[(10, 14)]
> python merge.py
(23,0),(0,1)
[(23, 1)]
> python merge.py
(0,8), (8,16), (16,0)
[(0, 0)]


text:
Race to a Million
This falls under the Code puzzles the best.  Fastest way to render the numbers 1-million in a web browser.  Preferably using PHP, but use what you must.  Numbers must be more than one on a line in the web browser and must line wrap (the horizontal scroll bar must not be triggered).
rules:

use any loop construct that you want
No horizontal scrolling allowed
Count 1 - 1,000,000 (commas not needed, overshoot is OK)
Must be a language that displays results in a browser.

For my timer, I'm using:
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;

before the code and
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$totaltime = ($endtime - $starttime);

echo ("

Total count time: ".$totaltime." seconds");

after the code.

How are you going to measure speed? Your puzzle is phrased in a way that suggests rendering speed matters the most - which is something that is very specific to the web browser but hard to control in unknown environments.

Indeed. You can either have a large page to send to the browser from the server, or create the content in the browser itself (by Javascript), or a combination of both methods. The differences in speed will depend on the situation.

Added my speed measurement code to the question.  However, any code that measures run time is satisfactory.

Why not use microtime(true) instead of doing your own math?

That was the code sample that I found with the puzzle.  I left it off initially because I knew there were more efficient ways but felt I would leave it up to the individual programmer to time-stamp it in their own way.

And no, I get no benefit out of this.  I just found it and thought it would be a fun addition for this site.

HTML
Just have a page with the numbers already in it! Encoded in base-36 for less characters and rendering time. 5 and a bit MB source so I'll just give you a little snippet:

1 2 3 4 5 6 7 8 9 a b c...

... pew2 pew3 pew4 pew5 pew6 pew7 pew8 pew9 pewa pewb pewc pewd pewe pewf pewg pewh pewi
 pewj pewk pewl pewm pewn pewo pewp pewq pewr pews pewt pewu pewv peww pewx pex0 pex1 pex2
 pex3 pex4 pex5 pex6 pex7 pex8 pex9 pexa pexb pexc pexd pexe pexf pexg pexh pexi pexj pexk
 pexl pexm pexn pexo pexp pexq pexr pexs pext pexu pexv pexw pexx pf00 pf01 pf02 pf03 pf04
 pf05 pf06 pf07 pf08 pf09 pf0a pf0b pf0c pf0d pf0e pf0f pf0g pf0h pf0i pf0j pf0k pf0l pf0m
 pf0n pf0o pf0p pf0q pf0r pf0s pf0t pf0u pf0v pf0w pf0x pf10 pf11 pf12 pf13 pf14 pf15 pf16
 pf17 pf18 pf19 pf1a pf1b pf1c pf1d pf1e pf1f pf1g pf1h pf1i pf1j pf1k pf1l pf1m pf1n pf1o
 pf1p pf1q

If you can be bothered, write this to an image with really small fontsize and it may increase rendering time!
Up to OP to figure out how to time this.
(This is barely a serious submission)

lol, I thought about that!  But, I didn't consider encoding it to base-36.  1-1,000,000 is a HUGE file in base-10.

Does base-36 really save you anything if your webserver is doing gzip?

@gnibbler yes, because it means rendering less digits..

@Griffin: But the entropy with base-36 is much higher than base-10 digits, so compression will be more efficient in base-10.  I just generated 1-1,000,000 in base 10, it was 6.7MB.  Then I generated 1-1,000,000 in base 36, it was 4.8MB.  Then I 7-zipped them (which should be relatively similar to gzip), and they compressed to 80KB, and 314KB, respectively.  So in fact, it seems the base 10 numbers would actually compress to a smaller size.

@mellamokb, who cares about compression, the digits still have to be displayed (therefore renedered) on the screen...

@Griffin: Ah, good point :)

There is something wrong with the first few numbers. They must be 1 2 3 4 5 6 7 8 9 a b c...

@ThomasW. yeah you're right, I typed that in manually when I posted, oops. Also, double oops: the numbers are actually base-34!

PNG, 7874 bytes
This renders almost instantaneously in Firefox. There are 512 numbers on each line. Each number is displayed in base 16,777,216 as a single RGB pixel, with the numerical value of each being 65536 * R + 256 * G + B. The horizontal scroll bar will not be triggered in Firefox when you view an image.

The image was created in Mathematica using
Image[
  Partition[
    Table[IntegerDigits[x, 256, 3], {x, 1, 1000000}],
    512, 512, {1, 1}, {{255, 255, 255}}],
  "Byte", Magnification -> 1]

, exported as a PNG, and optimized.

Upvoted because I laughed hard at your "base 16,777,216" solution. It's up to the OP to clearly define "a language that displays results in a browser". PHP may be the only programming language that started life as HTML template and fits the bill in a strict fashion. But yeah, why not PiNG, XSLT and any other type that renders in browser.

HTML / Javascript
A semi-serious attempt. This is, in my opinion, one of the only sane ways to go about the problem. Render time is approximately 1-2 seconds for every browser I checked.

    <title>Count</title>

    <textarea id="output_area"></textarea>

Using ruby and the web-framework sinatra:
# file: million.rb
require 'sinatra';get '/million.txt' do (1..(10*100*1000)).to_a.join("\n") end

Usage (requires ruby installed):
gem install sinatra
ruby million.rb

Then open http://0.0.0.0:4567/million.txt in any browser - took 636 ms hosted locally, opened in google-chrome.
Have fun ;)


text:
Solitaire Dreams - Creating a winnable solitaire starting hand
It's me. Cave Johnson.
It's May 21st. You are working at Aperture Science, finest company on Earth, and tomorrow we're releasing Version 3.0 of our flagship windowing system (or WindowS): CavOS. Unfortunately, tomorrow morning, our chief competitor is releasing Version 3.0 of their WindowS too!
It's been leaked to me, Cave Johnson, CEO that the competing WindowS has one feature that CavOS lacks: A game of Klondike Solitaire. I, Cave Johnson, am concerned that this omission will lead to drastically lower sales. As such, I, Cave Johnson, have devised a competition between the programming interns to create a game of Solitaire. The programmer whose entry is chosen will get the opportunity to join the exciting GlaDOS AI project.
I, Cave Johnson, has a few requirements:

Due to the fact that the Software must ship tomorrow, the shortest program will be chosen such that it can fit in the spare sectors of the already printed, imaged floppies.
Don't worry about the gameplay. Our customers have printers don't they? All I need is for your program to produce a list showing: The order of the cards in the deck, and the contents of each of the 7 piles. The deck will be dealt from the top. The piles will be visible from the bottom. Use the abbreviations H, D, C, S for Hearts, Diamonds, Clubs and Spades. Use the abbreviations K, Q, J, A for King, Queen, Jack, and Ace. Each card should be separated by a space. The first line should show the deck, the second the card of the first and smallest pile, the third the cards of the second pile and so on. You are welcome to use T instead of 10 if you wish.
We're making lemonade here - not sucking lemons. I, Cave Johnson, don't like losing, and neither do our customers. Every game must be winnable
The game must be randomised. No attempting to encode a single game. There are  7000 trillion possible Klondike hands, and about 90% of them are winnable. I'd be happy with a program that can produce 256 or more different hands. If your language lacks a manner to get random numbers (from a timer or the like), then assume that you can get a seed in a manner appropriate for your language.
Our customers are reasonably clever. Assume for winnability that they're playing Draw 3, with no limits on times through the deck

On behalf of everybody (and everything) at Aperture, I wish you all good luck. We're counting on you.
"Caroline? How do I shut this damn thing off?"

Out of character: assume the rules of Windows, Draw 3, Not-vegas solitaire. I've attempted to cross every t and dot every i, but ask if you've any questions. Good luck.
Example output:
5H AS 7C 8S QH ...
AH
JS 10S
JC JH 7C
9D AC 8D 7C
.
.
.

Can we use 'T' for 10, so every card is 2 characters?

I think our customers are clever enough to go for that. I'll add it to the description.

Brainfuck - 1575 1365
I am horribly abusing the minimum number of unique deals. This will produce exactly 256 distinct outputs. It accepts one byte of input as its random seed.
,>++++[>++++++<-]<[->+>-[>+>>]>[+[-<+>]>+>>]<<<<<<]>>>[<+<<+>>>-]>[-]<
<-[>+<-]<[->+>-[>+>>]>[+[-<+>]>+>>]<<<<<<]>[-]>[-]>[<<<+>>>-]>[-]+[>+<
+++++]>+++++[>+>>+>>+>>+>>+>>+>>+>>+>>+>>+>>+>>+>>+>>+>>+>>+>>+>>+>>+>
>+>>+>>+>>+>>+[<<]>-]>>>>>>>>>+>>+>>+>>+>++++++[>++++>>++++>>++++>>+++
+>>+++>>+++>>+++>>+++>>++++>>++++>>++++>>++++>>+++>>+++>>+++>>+++<<<<<
<<<<<<<<<<<<<<<<<<<<<<<<<<-]>++++>>++++>>++++>>++++>>>>>>>>>>+>>+>>+>>
+>>+>>+>>+>>+[<<]>>[>+<-<+>]>[<+>-]<<+++++++++++[>>+>>+>>+>>+>>+>>+>>+
>>+>>+>>+>>+>>+>>+>>+>>+>>+>>+>>+>>+>>+>>+>>+>>+>>+[<<]>>-]>>>>+>>++++
+>>++++++++++++++++>>>>+>>+++++>>++++++++++++++++>>>>+>>+++++>>+++++++
+++++++++>>>>+>>+++++>>++++++++++++++++>>>>+>>+++++>>++++++++++++++++>
>>>+>>+++++>>++++++++++++++++[<<]<<<<<<[>>>>>>+<<<<<<-]>>>>>>[>[<<+>>-
]<[>+<-]>>[<<+>>-]<-[>+<-]>]>.[-]>.[-]>[[<<<<+>>>>-]>]<<<<<[<<]<++++[>
++++++++<-]>.[-]<<<[>>>+<<<-]>>>[>[<<+>>-]<[>+<-]>>[<<+>>-]<-[>+<-]>]>
.[-]>.[-]>[[<<<<+>>>>-]>]<<++++[>++++++++<-]>.[<<<+>>>-]<<<<<[.[-]>.[-
]>.[<<+>>-]<<<<]>>[>+>++>++<<<-]++++++++++.>>+>+++<.>.<<<.>>----------
-----.+>.<<.>.+>.<<<.>>.+>.<<.>.+>.<<.>.+>.<<<.>>.>.<<.>++++++++++.>+.
<<.>---------------.+>.<<.>.+>.<<<.>>.+>.<<.>.+>.<<.>.+>.<<.>.+>.<<.>+
++++++++.>++++.<<<.>>---------------.+>.<<.>.+>.<<.>.+>.<<.>.+>.<<.>.+
>.<<.>.+>.<<<.>>+++++++++.>+++++++++++.<<.>---------------.+>.<<.>.+>.
<<.>.+>.<<.>.+>.<<.>.+>.<<.>.+>.<<.

Could definitely be condensed more, but that is kinda the nature of the language. This is quick and dirty, and it works.
Example output (input = 98):
8H 9S KS KH KD KC QS QH QD QC JS JH JD JC TS TH TD TC 9H 9D 9C 8S 8D 8C
AC
2C 3C
4C 5C 6C
7C AD 2D 3D
4D 5D 6D 7D AH
2H 3H 4H 5H 6H 7H
AS 2S 3S 4S 5S 6S 7S

It is fairly intuitive that all decks of this format are winnable.

Wonderful codegolf typical rule bending solution. And it even is Brainfuck - well done!


text:
Count the number of cyclic words in an input
Cyclic Words

Problem Statement
We can think of a cyclic word as a word written in a circle. To
  represent a cyclic word, we choose an arbitrary starting position and
  read the characters in clockwise order. So, "picture" and "turepic"
  are representations for the same cyclic word.
You are given a String[] words, each element of which is a
  representation of a cyclic word. Return the number of different cyclic
  words that are represented.

Fastest wins (Big O, where n = number of chars in a string)

If you're looking for criticism of your code then the place to go is codereview.stackexchange.com .

Cool. I'll edit for emphasis on the challenge and move the criticism part to code review. Thanks Peter.

What's the winning criteria? Shortest code (Code Golf) or anything else? Are there any limitataions on the form of input and output? Do we need to write a function or a complete program? Does it have to be in Java?

Well the ideal criteria I had in mind was big o time complexity, but we can do length if you like. Sorry, I am new to this. :/

@eggonlegs We are asking, not telling you about the criteria. It's just that this is a site where we pose and answer challanges, and we like them to have a metric that allows us to judge the "winner". Tags like code-golf, code-challenge, king-of-the-hill and details in the text are used to indicate the rules. [Code-challenge] is most general.

Understood. Okay, 'fastest-code' it is. :)

@eggonlegs You specified big-O - but with respect to which parameter? Number of strings in array? Is string comparison then O(1)? Or number of chars in string or total number of chars? Or anything else?

Sorry Howard, this was never really meant to be a code golf question, but I have updated it anyway. I want to take into account the speed of the comparison itself.

@eggonlegs What is the count of the list {"teaks", "words", "spot", "pots", "sword", "steak", "hand"}? 3 or 6?

@dude, surely it's 4?

So. You group words together that are rotations of each other and then count the groups. Fair enough.

@dude yes, it is 4

I'll try to do a better job posting a question next time ^_^

Python
Here's my solution. I think it might still be O(n2), but I think the average case is much better than that.
Basically it works by normalizing each string so that any rotation will have the same form. For example:
'amazing' -> 'mazinga'
'mazinga' -> 'mazinga'
'azingam' -> 'mazinga'
'zingama' -> 'mazinga'
'ingamaz' -> 'mazinga'
'ngamazi' -> 'mazinga'
'gamazin' -> 'mazinga'

The normalization is done by looking for the minimum character (by char code), and rotating the string so that character is in the last position. If that character occurs more than once, then the characters after each occurrence are used. This gives each cyclic word a canonical representation, that can be used as a key in a map.
The normalization is n2 in the worst case (where every character in the string is the same, e.g. aaaaaa), but most of the time there's only going to be a few occurrences, and the running time will be closer to n.
On my laptop (dual core Intel Atom @ 1.66GHz and 1GB of ram), running this on /usr/share/dict/words (234,937 words with an average length of 9.5 characters) takes about 7.6 seconds.
#!/usr/bin/python

import sys

def normalize(string):
   # the minimum character in the string
   c = min(string) # O(n) operation
   indices = [] # here we will store all the indices where c occurs
   i = -1       # initialize the search index
   while True: # finding all indexes where c occurs is again O(n)
      i = string.find(c, i+1)
      if i == -1:
         break
      else:
         indices.append(i)
   if len(indices) == 1: # if it only occurs once, then we're done
      i = indices[0]
      return string[i:] + string[:i]
   else:
      i = map(lambda x:(x,x), indices)
      for _ in range(len(string)):                       # go over the whole string O(n)
         i = map(lambda x:((x[0]+1)%len(string), x[1]), i)  # increment the indexes that walk along  O(m)
         c = min(map(lambda x: string[x[0]], i))    # get min character from current indexes         O(m)
         i = filter(lambda x: string[x[0]] == c, i) # keep only the indexes that have that character O(m)
         # if there's only one index left after filtering, we're done
         if len(i) == 1:
            break
      # either there are multiple identical runs, or
      # we found the unique best run, in either case, we start the string from that
      # index
      i = i[0][0]
      return string[i:] + string[:i]

def main(filename):
   cyclic_words = set()
   with open(filename) as words:
      for word in words.readlines():
         cyclic_words.add(normalize(word[:-1])) # normalize without the trailing newline
   print len(cyclic_words)

if __name__ == '__main__':
   if len(sys.argv) > 1:
      main(sys.argv[1])
   else:
      main("/dev/stdin")

Python (3) again
The method I used was to calculate a rolling hash of each word starting at each character in the string; since it's a rolling hash, it takes O(n) (where n is the word length) time to compute all the n hashes. The string is treated as a base-1114112 number, which ensures the hashes are unique. (This is similar to the Haskell solution, but more efficient since it only goes through the string twice.)
Then, for each input word, the algorithm checks its lowest hash to see if it's already in the set of hashes seen (a Python set, thus lookup is O(1) in the set's size); if it is, then the word or one of its rotations has already been seen. Otherwise, it adds that hash to the set.
The command-line argument should be the name of a file that contains one word per line (like /usr/share/dict/words).
import sys

def rollinghashes(string):
    base = 1114112
    curhash = 0
    for c in string:
        curhash = curhash * base + ord(c)
    yield curhash
    top = base ** len(string)
    for i in range(len(string) - 1):
        curhash = curhash * base % top + ord(string[i])
        yield curhash

def cycles(words, keepuniques=False):
    hashes = set()
    uniques = set()
    n = 0
    for word in words:
        h = min(rollinghashes(word))
        if h in hashes:
            continue
        else:
            n += 1
            if keepuniques:
                uniques.add(word)
            hashes.add(h)
    return n, uniques

if __name__ == "__main__":
    with open(sys.argv[1]) as words_file:
        print(cycles(line.strip() for line in words_file)[0])

Mathematica
Decided to start again, now that I understand the rules of the game (I think).
A 10000 word dictionary of unique randomly composed "words" (lower case only) of length 3.  In similar fashion other dictionaries were created consisting of strings of length 4, 5, 6, 7, and 8.
ClearAll[dictionary]
dictionary[chars_,nWords_]:=DeleteDuplicates[Table[FromCharacterCode@RandomInteger[{97,122},
chars],{nWords}]];
n=16000;
d3=Take[dictionary[3,n],10^4];
d4=Take[dictionary[4,n],10^4];
d5=Take[dictionary[5,n],10^4];
d6=Take[dictionary[6,n],10^4];
d7=Take[dictionary[7,n],10^4];
d8=Take[dictionary[8,n],10^4];

gtakes the current version of dictionary to check. The top word is joined with cyclic variants (if any exist). The word and its matches are appended to the output list, out, of processed words. The output words are removed from the dictionary.
g[{wds_,out_}] :=
   If[wds=={},{wds,out},
   Module[{s=wds[[1]],t,c},
   t=Table[StringRotateLeft[s, k], {k, StringLength[s]}];
   c=Intersection[wds,t];
   {Complement[wds,t],Append[out,c]}]]

f runs through all words dictionary.
f[dict_]:=FixedPoint[g,{dict,{}}][[2]]

Example 1: actual words
r = f[{"teaks", "words", "spot", "pots", "sword", "steak", "hand"}]
Length[r]

{{"steak", "teaks"}, {"hand"}, {"pots", "spot"}, {"sword", "words"}}
4

Example 2: Artificial words. Dictionary of strings of length 3. First, timing. Then the number of cycle words.
f[d3]//AbsoluteTiming
Length[%[[2]]]

5402

Timings as a function of word length.  10000 words in each dictionary.

I don't particularly know how to interpret the findings in terms of O. In simple terms, the timing roughly doubles from the three character dictionary to the four character dictionary.
The timing increases almost negligibly from 4 through 8 characters.

Can you possibly post a link to the dictionary you used so I can compare against yours?

The following link to dictionary.txt should work: http://bitshare.com/files/oy62qgro/dictionary.txt.html  (Sorry about the minute you'll have to wait for the download to begin.)  BTW, the file has the 3char, 4char...8char dictionaries all together, 10000 words in each.  You'll want to separate them.

Haskell
Not sure about the efficiency of this, most likely rather bad.
The idea is to first create all possible rotations of all the words,
count the values that uniquely represent the strings and select the
minimum. That way we get a number that is unique to a cyclic group.
We can group by this number and check the number of these groups.
If n is the number of words in the list and m is the length of a word
then calculating the 'cyclic group number' for all the words is O(n*m),
sorting O(n log n) and grouping O(n).
import Data.List
import Data.Char
import Data.Ord
import Data.Function

groupUnsortedOn f = groupBy ((==) `on` f) . sortBy(compare `on` f)
allCycles w = init $ zipWith (++) (tails w)(inits w)
wordval = foldl (\a b -> a*256 + (fromIntegral $ ord b)) 0
uniqcycle = minimumBy (comparing wordval) . allCycles
cyclicGroupCount = length . groupUnsortedOn uniqcycle

This can be done in O(n) avoiding quadratic time. The idea is to construct the full circle traversing the base string twice. So we construct "amazingamazin" as the full circle string to check all cyclic strings corresponding to "amazing".
Below is the Java solution:
public static void main(String[] args){
    //args[0] is the base string and following strings are assumed to be
    //cyclic strings to check
    int arrLen = args.length;
    int cyclicWordCount = 0;
    if(arrLen<1){
        System.out.println("Invalid usage. Supply argument strings...");
        return;
    }else if(arrLen==1){
        System.out.println("Cyclic word count=0");
        return;
    }//if

    String baseString = args[0];
    StringBuilder sb = new StringBuilder();
    // Traverse base string twice appending characters
    // Eg: construct 'amazingamazin' from 'amazing'
    for(int i=0;i<2*baseString.length()-1;i++)
        sb.append(args[0].charAt(i%baseString.length()));

    // All cyclic strings are now in the 'full circle' string
    String fullCircle = sb.toString();
    System.out.println("Constructed string= "+fullCircle);

    for(int i=1;i<arrLen;i++)
    //Do a length check in addition to contains
     if(baseString.length()==args[i].length()&&fullCircle.contains(args[i])){
        System.out.println("Found cyclic word: "+args[i]);
        cyclicWordCount++;
    }

    System.out.println("Cyclic word count= "+cyclicWordCount);
}//main

I don't know if this is very efficient, but this is my first crack.
private static int countCyclicWords(String[] input) {
    HashSet<String> hashSet = new HashSet<String>();
    String permutation;
    int count = 0;

    for (String s : input) {
        if (hashSet.contains(s)) {
            continue;
        } else {
            count++;
            for (int i = 0; i < s.length(); i++) {
                permutation = s.substring(1) + s.substring(0, 1);
                s = permutation;
                hashSet.add(s);
            }
        }
    }

    return count;
}

Perl
not sure i understand the problem, but this matches the example @dude posted in the comments at least. please correct my surely incorrect analysis.
for each word W in the given N words of the string list, you have to step through all characters of W in the worst case. i have to assume the hash operations are done in constant time.
use strict;
use warnings;

my @words = ( "teaks", "words", "spot", "pots", "sword", "steak", "hand" );

sub count
{
  my %h = ();

  foreach my $w (@_)
  {
    my $n = length($w);

    # concatenate the word with itself. then all substrings the
    # same length as word are rotations of word.
    my $s = $w . $w;

    # examine each rotation of word. add word to the hash if
    # no rotation already exists in the hash
    $h{$w} = undef unless
      grep { exists $h{substr $s, $_, $n} } 0 .. $n - 1;
  }

  return keys %h;
}

print scalar count(@words), $/;

Rust, brute force
run it on Rust Playground!
use std::collections::HashSet;
use std::time::Instant;

fn count_cyclic_words(input: &[&str]) -> usize {
    let mut hash_set = HashSet::new();
    let mut count = 0;

    for &s in input.iter() {
        if hash_set.contains(s) {
            continue;
        } else {
            count += 1;
            let mut permutation = String::from(s);
            for _ in 0..s.len() {
                permutation = format!("{}{}", &permutation[1..], &permutation[0..1]);
                hash_set.insert(permutation.clone());
            }
        }
    }

    count
}

fn main() {
    let test_cases = vec![
        vec!["abc", "cab", "bca"],
        vec!["aaa", "aaa", "aaa"],
        vec!["a", "b", "c"],
    ];

    for (i, input) in test_cases.iter().enumerate() {
        let start = Instant::now();
        let count = count_cyclic_words(input);
        let duration = start.elapsed();
        println!("Test case {}: count = {}", i + 1, count);
        println!("Time elapsed: {:?}", duration);
    }
}

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Rectangle of text
Your program gets a text as an input, at least 8 characters long, and always consisting of even number of characters. (no need to evaluate correctness of input).
Your goal is to display that text as a rectangle. For example, given HelloWorld as an input, display
Hell
d  o
lroW

Rules:

Text goes around clockwise (starting position as you like)
It will form a closed rectangle, sides 1 character wide.
The rectangle will have to encompass the most area inside. (just to rule out the trivial answer of displaying the text in two lines)
No other characters are printed besides the text itself and the necessary padding spaces and line feeds.

As code-golf, shortest code wins.
Winner is selected not sooner than 10 days after first valid answer.

GolfScript, 56 53 40 38 characters
1/..,4/):l<n@l>{)" "l*2>@(n@.,l-}do-1%

You may test the script online.

Ruby 112 100
I'm new to Ruby and this is my first code golf. I drew upon memowe's perl implementation and tried to make a Ruby version of it. This is 112 100 characters and assumes you assign a string to x. Looking forward to seeing others.
l=x.size
puts x[0..w=l/2-h=l/4]
1.upto(h-1){|i|puts x[-i]+' '*(w-1)+x[w+i]}
puts x[w+h..l-h].reverse

Edited to implement suggestions. I think it's 100 characters now. Thanks guys!

Nice! You can save two chars in the 5th line (remove spaces).

I like it. Thanks. Looks good that Ruby strings can be accessed like an array, I had to built one by myself. :)

You could replace x.length with x.size (Saves 2 characters)

And 8 more using puts x[0..w=l/2-h=l/4].

PostScript 50 binary, 113 ASCII
This uses graphical output. Hexdump of the program using binary tokens:
$ hexdump -C textRect_binary.ps
00000000  74 5b 30 20 39 5b 74 92  62 34 92 36 92 38 92 10  |t[0 9[t.b4.6.8..|
00000010  32 92 19 5d 7b 92 2c 7b  32 92 19 7d 92 83 92 3e  |2..]{.,{2..}...>|
00000020  92 6e 7d 92 49 5d 39 20  39 92 6b 91 c7 39 92 8e  |.n}.I]9 9.k..9..|
00000030  92 c3                                             |..|
00000032

Download to try it. Using Ghostscript, the to-be-rendered text can be passed to the program as follows:
gs -st=helloworld textRect_binary.ps

Graphical output looks like this:

The same code using ASCII tokens looks like this:
t[0 9[t length
4 div dup
ceiling
2 copy]{cvi{2 copy}repeat
exch neg}forall]9 9 moveto/Courier 9 selectfont
xyshow

The strategy is to use xyshow for defining where we move after showing each character before showing the next character. We're starting in the lower left corner, moving clockwise, i.e. first up, then right, then down then left. We're always moving 9 units, so first we have a relative movement of 0 9, then 9 0, then 0 -9, then -9 0. We can get from one pair of these numbers to the next with the sequence exch neg.
We need to build an array for xyshow that holds these pairs of numbers, one pair for each character. This means, if we have helloworld as example string, which has 10 characters, we want to go up twice, then right thrice, then down twice and left thrice. We get these values (two and three) by dividing the string length by 8, once rounding to the floor, once to the ceiling.
So, we copy 0 9 twice, then switch to the relative x/y coordinates using exch neg, copy those thrice and so on.
This commented code shows what happens on the stack:
t[0 9                % t [ 0 9
[t length            % t [ 0 9 [ length
4 div dup            % t [ 0 9 [ length/4 length/4
ceiling              % t [ 0 9 [ length/4=height width
2 copy]              % t [ 0 9 [height width height width]
{%forall             % t [ 0 9 ... x y height_or_width
  cvi                % t [ 0 9 ... x y height_or_width_integer
  {2 copy}           % t [ 0 9 ... x y height_or_width_integer {2 copy}
  repeat             % t [ 0 9 ... x y .. x y
  exch neg           % t [ 0 9 ... x y .. y -x
}forall]             % t [0 9 ... -9 0]
9 9 moveto/Courier 9 selectfont
xyshow

+1 holy bajeezus. I'm seriously deficient in my knowledge of level-2 and beyond.

You mean xyshow? Happy to introduce you to this one--some time ago you introduced me to kshow, which I wasn't really aware of ;-).

@luserdroog: BTW: I'm pretty proud that the current GolfScript entry has more than 10% more characters than my binary entry, but it bugs me that my ASCII version is one character away from a draw with Ruby (actually, even three, because the Ruby code could be golfed further). Do you have any ideas for further optimization?

@ThomasW. Now my GolfScript entry is 24% shorter than your binary ;-) And I still think there is still the chance to shorten it even further by one or two chars.

@Howard: Argh!!! Can anyone ever beat GolfScript?

Perl (124 118 109+3=112)
This formerly was pretty straightforward. Counted all command line options as 1 character each.
-nlE
$w=(@s=split//)/2-($h=int@s/4);say@s[0..$w--];say$s[1-$_].$"x$w.$s[$w+$_]for+2..$h;say+reverse@s[@s/2..@s-$h]

Example:
$ perl -nlE '$w=(@s=split//)/2-($h=int@s/4);say@s[0..$w--];say$s[1-$_].$"x$w.$s[$w+$_]for+2..$h;say+reverse@s[@s/2..@s-$h]'
abcdefghijklmnopqrstuvwxyz
abcdefgh
z      i
y      j
x      k
w      l
v      m
utsrqpon

This can be compacted: (1) (@s-$h*2)/2 == @s/2-$h (2) $w can be represented as $w=(@s=split//)/2-($h=int@s/4);, thus saving two semicolons

Updated the code.

Further interesting stuff: (1) the space is the default value of the array interpolation var $"–saves 1 char. (2) $w+$h == @s/2–saves 1 char. (3) If $w is smaller by one, we can simplify $"x($w-1). For this, the $_ has to be increased by 1. Saves like 3 chars. (4) The final semicolon is überflüssig, saves 1 char. This leads to the code fragment say@s[0..$w--];say$s[1-$_].$"x$w.$s[$w+$_]for+2..$h;say+reverse@s[@s/2..@s-$h] (with a few + for fun, so there isn't a single space left).

Excellent golfification, @amon, would you edit it in my post please? That way the world can see who did it. :)

Brainfuck - 194 187
+>,[>+[>+<-],]
>-->++<[->-[>+>>]>[+[-<+>]>+>>]<<<<<]>[-]>[-]>[<<+<<+>>>>-]<<<<
[[<]>+[>]<-]<[<]>-
[>.[-]<[>+<-]>-]>[>]
++++++++++.<.[-]
>[>+++>>+<<<-]>++>--[<.>-]<<<<[<]>.[-]>[>]>>>>.
<<<<<[.<]

Nice try, but it does not work. The bottom line is in the wrong direction, contrary to rule 1, and it only has a fixed height, contrary to rule 3.

Not sure why I flipped the last row. I totally had it in mind the correct way as I was writing it. The fix actually saves 7 commands. I did cop out on the fixed height thing, but its not the trivial, 2 line case you talked about. Maybe I'll make it better in the future.

Mathematica 156 199 344
Edit : This is a major rewrite of earlier code. It works essentially the same, but now takes as input a string of length < 120 chars and automatically sizes the square.
It could still be golfed a bit but will not get down to the size of the earlier, and buggier, versions.
f@s_ := ({a, t, w, q} = {Automatic, Text, Quotient[StringLength@s, 2],
 Quotient[StringLength[s], 4] + 1};z = StringSplit[StringInsert[s <> ConstantArray[" ", 0],
 "*", {q, 2 q, 3 q}], "*"];
Graphics[{t[z[[1]], {0, q}],t[z[[2]], {q, 0}, a, {0, -1}],t[z[[3]], {0, -q}, a, {-1, 0}],
t[z[[4]], {-q, 0}, a, {0, 1}]},ImageSize -> 500,BaseStyle -> {FontFamily -> "Courier", 21},
PlotRange -> 34,ImagePadding -> 22])

Examples
f["Hello Code Golf World!"]
f["January, February, March,April, May, June, July"]
f["This text is normal, this goes downwards,this is upside-down, and this is upwards"]

Hey, an array of strings? That's really bending the rules, isn't it?

@ThomasW. The comments in the answer indicate it's not a final solution.

Ah, I see! Wonder whether I should take the challenge and try something similar in PostScript...

I like how it looks now!

@Thomas W. Thanks. Getting the format to look right  for a wide range of string lengths cost a lot of bytes.

I have a similar PostScript solution in just a moment...

Perl + Regexes: 104 (101+3)
(counting code + switches)
Here is a solution using nice Regexes, and a bit of Perl:
perl -plE'$w=($l=length)/2-($h=int$l/4);s/..{$w}\K.*/"\n".reverse$&/e;$"x=--$w;s/.\K(.*)(.)$/$"$2\n$1/while--$h'

This will only operate correctly on one input line.
Inspired by memowe, but essentially without any arrays.

Sorry for the dumb question: How can I try this out? I'm pasting your code to the command line, then type something, press enter and something comes out. But it's not a box. What am I doing wrong?

@ThomasW. It seems to work for me, for an arbitrary even number of chars. The above code is guaranteed to work under bash and perl version 5.12+. Input is accepted via STDIN, and only the first line is processed correctly. I don't know how to quote the code correctly for cmd.exe.

Ah, was probably my mistake. I probably used a string of odd length. This works: echo thisworksgreat | perl -plE'$w=($l=length)/2-($h=int$l/4);s/..{$w}\K.*/"\n".reverse$&/e;$"x=--$w;s/.\K(.*)(.)$/$"$2\n$1/while--$h'

PostScript (106)
This is inspired by dude's Mathematica solution.
0{= =
4 add dup
t length mod 4
lt{-90 rotate}if}0[0 3 -3 0 9 9]concat
0 moveto/Courier 5 selectfont
t kshow

With Ghostscript call this like
gs -st=hello! boxtext.ps

It produces output like.

It uses kshow to show the glyphs one by one. After enough glyphs for one side have been shown, everything is rotated by -90 degrees before continuing with the remaining glyphs.
To know when enough glyphs have been shown on the side, we increment a counter by 4 each time a glyph is shown. If the counter value modulo the string length is less than 4, then we know we have to rotate:
char  counter  mod 6  compared to 4
 h       4       4          =
 e       8       2          <   => rotate
 l      12       0          <   => rotate
 l      16       4          =
 o      20       2          <   => rotate
 !      24       0          <   => rotate

Commented and un-golfed source code:
0                      % n
{%kshow                % n char1 char2
  = =                  % n
  4 add dup            % n' n'
  t length mod         % n' (n' mod t_length)
  4 lt                 % n' bool
  {-90 rotate}if       % n'
}                      % n kshowProc
% First 0 for moveto. We add it here to take
% advantage of the surrounding self delimiting tokens.
0                      % n kshowProc 0
% We change the graphics state so that the drawn
% text is at a nice size and not off screen.
[0 3 -3 0 9 9]concat   % n kshowProc 0
0                      % n kshowProc 0 0
moveto                 % n kshowProc
/Courier 5 selectfont  % n kshowProc
t                      % n kshowProc text
kshow                  % n

Python 3(120)
s=input()
n=len(s)
h=n//4
q=(n+2)//4-1
p=print
p(s[:q+2])
for i in range(1,h):p(s[n-i]+' '*q+s[q+1+i])
p(s[n-h:q+h:-1])

Test
input:
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz

output:
abcdefghijklmn
z            o
y            p
x            q
w            r
v            s
u            t
t            u
s            v
r            w
q            x
p            y
o            z
nmlkjihgfedcba

05AB1E, 19 17 bytes
g4/Dîsï‚>4∍IŽ9¦SΛ

Port of my Charcoal answer.
Try it online.
Explanation:
g            # Get the length of the (implicit) input-string
 4/          # Divide it by 4
   D         # Duplicate it
    î        # Ceil the copy
     sï      # Swap, and floor the other one
       ‚     # Pair the two together
        >    # Increase both by 1
         4∍  # And extend it to size 4
I            # Push the input-string
Ž9¦          # Push compressed integer 2460
   S         # And convert it to a digit-list: [2,4,6,0]
Λ            # Use the Canvas builtin with these three arguments
             # (which is implicitly output immediately as result)

See this 05AB1E tip of mine (section How to compress large integers?) to understand why Ž9¦ is 2460.
The Canvas builtin takes three arguments:

The length of the lines. For this we use the list of four values we created at the start: \$\left[ \left\lceil\frac{L}{4}\right\rceil+1, \left\lfloor\frac{L}{4}\right\rfloor+1, \left\lceil\frac{L}{4}\right\rceil+1, \left\lfloor\frac{L}{4}\right\rfloor+1 \right]\$.
The characters we want to display, which is the input-string.
The directions in which to draw, which is [2,4,6,0]. These directions map to [→,↓,←,↑].

For a more detailed explanation of the Canvas builtin, see this 05AB1E tip of mine.

K, 84
{-1'(*r;((|r 3),\:(w-2)#" "),'r 1;|(r:(0,+\(w;h;w;h:_(l-2*w:-_-(1+(l:#x)%4))%2))_x)2);}

.
k){-1'(*r;((|r 3),\:(w-2)#" "),'r 1;|(r:(0,+\(w;h;w;h:_(l-2*w:-_-(1+(l:#x)%4))%2))_x)2);}"HelloWorld"
Hell
d  o
lroW

k){-1'(*r;((|r 3),\:(w-2)#" "),'r 1;|(r:(0,+\(w;h;w;h:_(l-2*w:-_-(1+(l:#x)%4))%2))_x)2);}"Hellooooooooooooooo Worlddddd!"
Hellooooo
!       o
d       o
d       o
d       o
d       o
d       o
lroW oooo

Scala (135)
The following snippet assumes that x contains the string to format, and should be pasted in the scala REPL:
val (h,w)=((x.size+3)/4,println(_:Any));val s=x.grouped(h)toSeq;w(s(0));for((l,r)<-s(1)zip(s(3)reverse))w(r+" "*(h-2)+l);w(s(2)reverse)

If you don't have scala installed, you can quickly check it using this online Scala interpreter: http://www.simplyscala.com/.
Just paste the following text end press evaluate:
val x="HelloWorld"
val (h,w)=((x.size+3)/4,println(_:Any));val s=x.grouped(h)toSeq;w(s(0));for((l,r)<-s(1)zip(s(3)reverse))w(r+" "*(h-2)+l);w(s(2)reverse)

Python 2.x: 137
I'm new to code golfing and quite sure this can be improved…
def s(t):c=len(t);w=1+c/4;h=(c-w-w)/2;u=w+h;n='\n';print t[:w]+n+n.join(map(((w-2)*' ').join,zip(t[:w+u-1:-1],t[w:u])))+n+t[w+u-1:u-1:-1]

Visual testing code:
from itertools import chain
from string import letters
for i in range(8,101,2):
    t = ''.join(chain(letters))[:i]
    print '%d: %s' % (i, t)
    s(t)
    print '-----'

Something of interest: This solution depends on integer math. If you just do the math symbolically, you'll find that h=(c-w-w)/2 => h=w-2, but if you substitute that result every other result will be missing two lower-left characters.

Charcoal, 16 12 bytes
Ｂ⊕Ｌ⪪θ⁴⊕⊘⊘Ｌθθ

-4 bytes thanks to @Neil.
Try it online (verbose) or try it online (pure).
Explanation:
Draw a box using the characters in the implicit input-string:
Box(..., ..., q);
Ｂ...θ

With a width \$\left\lceil\frac{L}{4}\right\rceil+1\$ (where \$L\$ is the length of the input), by splitting the input-string into parts of size 4 and getting this list's length incremented by 1:
Incremented(Length(Split(q,4)))
⊕Ｌ⪪θ⁴

And height \$\left\lfloor\frac{L}{4}\right\rfloor+1\$:
Incremented(IntDivide(Length(q),4))
⊕⊘⊘Ｌθ

I've come up with two 14-byte variations: ＳθＢ⊕Ｌ⪪θ⁴⊕⊘⊘Ｌθθ and Ｓθ≔⊕⊘⊘ＬθηＢ⌈ηηθ. Also strictly speaking the Ｓθ is unnecessary.

@Neil Thanks! Can't believe I forgot about q being implicitly filled with an input-string and only the input-integer being mandatory. And thanks for the additional -2. Nice alternative as well! :)

Your verbose explanation doesn't match your verbose link.

@Neil Ah, you're indeed correct. Should be fixed now.

PHP (149)
The text to print should be in a variable named $x.
@$s=substr;echo$s($x,-$w=($l=strlen($x)/2)-$h=$i=$l-2>>1).'
';while($i--)echo$x[$l+$i].str_repeat(' ',$w-2).$x[$h-$i-1].'
';echo$s(strrev($x),$l,$w);

JAVA - 320
public class A{
public static void main(String[] a){
String s=a[0];
int l=s.length(),h=l/2,f=h-1,i=0;
for(i=0;i<f;i++)
System.out.print(s.charAt(i));
System.out.print("\n"+s.charAt(l-1));
for(i=0;i<f-2;i++)
System.out.print(" ");
System.out.println(s.charAt(h-1));
for(i=l-2;i>h-1;i--)
System.out.print(s.charAt(i));}}

Note : - Input is taken from command line
Input : - HelloWorld
Output : -
Hell
d  o
lroW

Input : - abcdefghijklmnopqrstuvwxyz
Output : -
abcdefghijkl
z          m
yxwvutsrqpon

Please read the rules more carefully, especially nr. 3.


text:
Find random images from http://i.imgur.com/

Imgur is a free image hosting service. Many people use it. Here is an example of an imgur link: https://i.stack.imgur.com/II8CA.png. Write a program that continually outputs random (valid) imgur links. For example, here is some sample output of my progam (not shown because it contains some tricks you will have to figure out yourself):
http://i.imgur.com/uFmsA.png
http://i.imgur.com/FlpHS.png
http://i.imgur.com/eAbsZ.png
http://i.imgur.com/lEUsq.png
http://i.imgur.com/RuveH.png
http://i.imgur.com/BoEwB.png
http://i.imgur.com/HVFGQ.png
http://i.imgur.com/PZpMg.png
http://i.imgur.com/DezCY.png

Helpful hints:

When imgur was new, 5-letter links were used.
When imgur was new, numbers weren't used.
You can use this to your advantage: only find 5-letter link images with only letters. That is what my program does.
Also, all images are saved as .png.

Requirements:

Continually output random imgur links
Links considered sufficiently "random" if 50 are outputted with no repeats
When visited, links must be an image
Links must start with http://i.imgur.com/ and end with .png
Score is amount of characters

I did it in Java (TERRIBLE for golfing) in 452 chars. Not shown here because it contains some tricks you will have to figure out for yourself!)

Wait, is your definition of random that the output shouldn't contain repeats?

Warning: pornographic images may be present on imgur! =:o

Are all 5-letter image valid?

PHP 5.4, 76 characters
URLs are generated in sequential order using only uppercase letters and never repeat, meeting the letter of the specification.
<?for($t=@ZZZZ;$t++;)file($u="http://i.imgur.com/$t.png")[0]>@F&&print"$u
";

HTML (152)
<img src=x
onload=console.log(s);g()
onerror=g=function(){s='http://i.imgur.com/'+Math.random().toString(36).substr(2,6)+'.png';event.target.src=s};g()>

This logs all found images on the JavaScript console using console.log(). Works in all tested browsers (Firefox, Chrome, IE9, Safari and Opera).
The fun part is that all sorts of funny images are flashing up for the blink of an eye :).
Try it! (jsFiddle wraps this into a more complete HTML page, but browsers also accept the single element.)
Props to the amazing random string method by doubletap!
Where can I see the JavaScript console and the logged images?

Firefox: Press Control-Shift-K (Command-Option-K on the Mac). Unselect the Net, CSS and JS buttons there, only select the Logging button.
Opera: Press Control+Shift+i, select the Console tab.
Chrome: Press Control+Shift+i, select the Console tab. On the bottom, select Logs.
Safari: Basically like Chrome, but make sure first that Safari's developer tools are activated. Then press Control+Alt+C (on Windows, not sure on the Mac) instead of Control+Shift+i, select the Console tab. On the bottom, select Logs.
IE: Press F12, select the console tab.

This does not meet the requirements. Many of the images it pops up are not valid.

What do you mean by "not valid"? In the console, only images that could be successfully displayed are logged (see my updated description).

Oh, okay. Retrying now. Edit: Chrome seems to be logging the invalid images as well.

Chrome by default mixes error messages and logs. At the bottom of the console tab you have All, Errors, Warnings, Logs. If an image could not be loaded, it displays a 404 error with the image URL. If you select Logs, then only the output generated by my code should display.

A lot of the logged image URLs just return the standard imgur error image that says "The image you are requesting does not exist or is no longer available."  I suppose one could argue that those are still valid results under the rules as given, since the returned document is an image.

@IlmariKaronen Yes, the standard error images are still valid. They are technically an image.

Perl (93 + 4 = 97)
Using imgur's own random mechanism to get their image URLs, which aren't png URLs most of the time:
$ perl -Mojo -E 'say+g("http://imgur.com/gallery/random")->dom->at("[rel=image_src]")->attrs("href")for+1..50'
http://i.imgur.com/7cNoA.jpg
...

(You need Mojolicious for this.)

That's brilliant, and so not fair!

@elssar That's right, at least your second point. ;)

Oh, that's clever :)

Perl (87)
perl -pe's/\W//g;$_="http://i.imgur.com/$_.png\n";$_=""if`curl $_`=~/^</'</dev/urandom

Finding images with uppercase, lowercase and digits from 0 up to any characters,
some day.

Hehehe, urandom

Mathematica, 108
White-space added.
While[True,
 Import@# /. _Image :> Print@# &[
  "http://i.imgur.com/" <> "a" ~CharacterRange~ "z" ~RandomChoice~ 5 <> ".png"
 ]
]

Python, 361 355 334 332 322 314 characters
A little obfuscated, nothing too difficult. May result in unusually high density of cat pictures, you have been warned.
import json as j,urllib as o,time as t;a=0
while 1:
 q="i.imgur";y,p=('data','children');r="njj";h="erqqvg.pbz/";u="uggc://"+h+"e/"+r;c=j.loads(o.urlopen(u.decode('rot13')+".json?sorted=new&after=%s"%a).read())[y]
 for s in c[p]:
  f=s[y];w=f['url'].strip('?1')
  if w.find(q)!=-1:print w
 a=c['after'];t.sleep(3)

Output:
http://i.imgur.com/u3vyMCW.jpg
http://i.imgur.com/zF7rPAf.jpg
http://i.imgur.com/aDTl7OM.jpg
http://i.imgur.com/KONVsYw.jpg
http://i.imgur.com/RVM2pYi.png
http://i.imgur.com/tkMhc9T.jpg
http://i.imgur.com/KxUrZkp.gif
http://i.imgur.com/mnDTovy.jpg
http://i.imgur.com/WpuXbHb.jpg
http://i.imgur.com/qZA3mCR.jpg
http://i.imgur.com/AxMS1Fs.png
http://i.imgur.com/TLSd571.jpg
http://i.imgur.com/VfMhLIQ.jpg
http://i.imgur.com/Wu32582.jpg
http://i.imgur.com/hrmQL2F.jpg
http://i.imgur.com/Clg8N.jpg
http://i.imgur.com/7Wsko.jpg
http://i.imgur.com/Rhb0UNx.jpg
http://i.imgur.com/LAXAf45.gif
http://i.imgur.com/jhOLJ9B.jpg
http://i.imgur.com/FQ9NeAl.jpg
http://i.imgur.com/oqzf6tE.jpg
http://i.imgur.com/rnpXs1A.jpg
http://i.imgur.com/DfUIz6k.jpg
http://i.imgur.com/orfGA5I.jpg
http://i.imgur.com/wBT7JNt.jpg
http://i.imgur.com/RycK1m2.jpg
http://i.imgur.com/7j21FIR.jpg
http://i.imgur.com/z2tVnNC.jpg
http://i.imgur.com/mnsAGuF.jpg
http://i.imgur.com/vIZM1NY.jpg
http://i.imgur.com/JT3XRI4.jpg
http://i.imgur.com/SNpwTmp.jpg
http://i.imgur.com/u9ynLb9.jpg
http://i.imgur.com/DrFWsBP.jpg
http://i.imgur.com/rU6oyup.jpg
http://i.imgur.com/XxBD5nl.jpg
http://i.imgur.com/d09qQzP.jpg
http://i.imgur.com/vvPSbqI.jpg
http://i.imgur.com/1hdfobQ.jpg
http://i.imgur.com/4LLC6Vs.jpg
http://i.imgur.com/RfasxO2.jpg
http://i.imgur.com/BBcpOos.jpg
http://i.imgur.com/zMH8mgG.jpg
http://i.imgur.com/7g8k2Ww.jpg

All the images... are animals? There is some trickery going on here :P +1 because I like the cute animals :3

Bash (129, 121) (117, 109)
I've got two versions: an iterative and an endless recursive one (which will slowly eat up all memory).
Both versions check if there actually is a PNG file present (jpg's, gif's and other file types are ignored).
Iterative(old) (129):
while true;do u=http://i.imgur.com/$(tr -dc a-zA-Z</dev/urandom|head -c5).png;curl $u -s 2>&1|head -c4|grep PNG$ -q&&echo $u;done

Recursive(old) (121):
:(){ u=http://i.imgur.com/$(tr -dc a-zA-Z</dev/urandom|head -c5).png;curl $u -s 2>&1|head -c4|grep PNG$ -q&&echo $u;:;};:

Note:
There might be a compatability issue with grep. My grep manual states that -s silents grep's output but it does nothing. However, using --quiet, --silent or -q instead works.
EDIT:
Using content headers now after reading https://codegolf.stackexchange.com/a/10499/7195 :)
Iterative (117):
while true;do u=http://i.imgur.com/$(tr -dc a-zA-Z</dev/urandom|head -c5).png;curl $u -sI|grep image -q&&echo $u;done

Recursive (109):
:(){ u=http://i.imgur.com/$(tr -dc a-zA-Z</dev/urandom|head -c5).png;curl $u -sI|grep image -q&&echo $u;:;};:

Python (174 158 156)
I want shorter module names in Python. Also an easier method of getting random letters. :)
import urllib,random
while 1:a='http://i.imgur.com/%s.png'%''.join(chr(random.randint(65,90))for i in'AAAAA');print('File'not in urllib.urlopen(a).read())*a

Explanation:
The modulus operator on a string is the formatting command, in this case it replaces '%s' in the string with 5 random uppercase letters
a is the website name (type str)
('File'not in urllib.urlopen(a).read()) is True when 'File' (from 'File not found!') is not found in the the HTML of the URL. (type bool)
bool * str = str if bool = True, so it will only output a if 'File' is not found in the HTML code.

What part of the spec says you have to use both upper and lower case letters? chr(random.randint(65,90))

I ran it and it didn't output anything. Nice trick with 'File' though :)

@PeterTaylor: :) I didn't know that there were any links on imgur with only uppercase letters, but I guess that would be obvious enough. Thanks!

@Doorknob: It outputs a newline unless a link is found, then it will give a link.

Any sequence of length 5 will work for your 5 random characters, so you can shave a few characters off by using something like 'XXXXX' rather than range(5). This also has the advantage of not requiring whitespace between it and the in.

@Strigoides: Links considered sufficiently "random" if 50 are outputted with no repeats?

I'm not sure what you mean. My point is, you're using for i in range(5) to repeat chr(random.randint(65,90)) 5 times. Since you don't actually use i, you can replace range(5) with any sequence of length 5, right?

@Strigoides: I thought you meant iterating through 'AAAAA' to 'ZZZZZ'. Now I understand, that's pretty clever. :) Thanks!

You can shave 2 chars if you import both the modules as a single character variable.

@elssar: It's the same length, I think. random as r r is the same length as random random.

Oh right, I didn't account for the r

R, 182 characters
library(httr);while(0<1){s=paste("http://i.imgur.com/",paste(sample(c(LETTERS,letters),5),collapse=""),".png",sep="");if(HEAD(s)$headers$'content-type'=='text/html')'' else print(s)}

Python, 153 chars
import string as s,random as w,requests as r
while 1:
 t='http://i.imgur.com/%s.png'%''.join(w.sample(s.letters,5))
 if'not'not in r.get(t).text:print t

While this works, it is bloody slow and might take many seconds before returning any output.
Inspired by @beary605's solution - he saved me a bunch of characters as I was planning to check for image by content-type header.

random.sample :) That is a much better way of choosing characters.

Yep, amazing what Code golf will force you to Google, and learn.

Ruby (103 chars)
require"open-uri";loop{u="http://i.imgur.com/#{rand(1e9).to_s(36)[0,5]}.png";open u rescue next;puts u}

You have to add a .png to the end of the URL.

@Doorknob: Whoops, fixed

Bash/command-line tools, 72 chars
Borrowing @memowe's clever technique:
curl -sL http://imgur.com/gallery/random|grep e_sr|cut -d\" -f4;exec $0

This achieves a continuous loop by re-execing itself within the same process space.

Jelly, 41 bytes
ØẠẊs5Ḣ
“http://i.imgur.com/”;¢;“.png”ṄƲÐḶ

How?
ØẠẊs5Ḣ  : Helper Link
ØẠ      : Upper and Lowercase Alphabet
  Ẋ     : Shuffle
   s5   : Split Into Lengths of 5
     Ḣ  : Head; pop from front of list
-----------------------------------------------------------------------------------------
“http://i.imgur.com/”;¢;“.png”ṄƲÐḶ  : Main Link
“http://i.imgur.com/”               : String Literal
                      ¢             : Previous link as a nilad.
                        “.png”      : String Literal
                     ; ;            : Concat
                              Ṅ     : Print with a linefeed
                               Ʋ    : Last four links as a monad
                                ÐḶ  : Loop; Repeat until the results are no longer unique.

Attempt This Online!

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/