As an example I offer this, which was used to clear the screen in COBOL.
DISPLAY SPACES UPON CRT
As an example I offer this, which was used to clear the screen in COBOL.
DISPLAY SPACES UPON CRT
while (true) System.out.println("SO isn't really meant for open-ended questions like this.");
This little one-liner kills the discussion.
(Sorry for the snarkiness, I think it's time for me to go home.)
From the Python FAQ
print map(lambda x,f=lambda x,f:(x<=1) or (f(x-1,f)+f(x-2,f)): f(x,f),range(10))
This question reminds me of the site The Daily WTF. Check it out if you've never heard of it before.
My favorite bash script thingy. Originally written by http://twitter.com/jf
curl -Is slashdot.org | egrep '^X-(F|B|L)' | cut -d \- -f 2
This is not super complex but I've always been charmed by this method of unbuffering IO on a file handle in perl without changing the currently selected file handle (er, technically it does change it, but it changes it back and you don't have to know what the currently selected file handle is)
select((select(SOMEFILEHANDLE), $| = 1)[0]);
For me, it must be the Jaromil bash forkbomb, looks like a poem :)
:(){ :|:& };:
This is an explanation of the Jaromil program
Also, the more concise Windows shell forkbomb is a sure winner in any golf match:
%0|%0
It's not really strange, but one bit of code that I've always found particularly amusing decrementing a value and checking it as it approaches zero, e.g.
while(foo-->0)
{
//...
}
//&>/dev/null;x="${0%.*}";[ ! "$x" -ot "$0" ]||(rm -f "$x";cc -o "$x" "$0")&&"$x" $*;exit
I'd call this the most useful. I put this at the top of any simple single-file C scripts, so that I can execute them directly. It compiles if necessary and calls the executable, passing on any parameters.
This is on all my forum signitures:
$me->selfDestruct('NOW');
or the ocassional
if($work.status == 'done'){ takeBreak(TRUE); }
however it always evaluates to false.
I don't know why but it has always tickled me when I run across this.
my @lines = map ( /:\s+(\S*)\s*$/, grep ( /Name/, <> ));");
My personal favorite I met in Schneier's "Applied Cryptography", to swap two integers:
x ^= y; y^= x; x^=y;
I always thought
while ((*dst++ = *src++) != '\0');
was an interesting use of pointers to copy a string.
A perl-regexp to check if a number is prime:
print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/
(I would like to give credit for this one, but I can't remember who actually dicovered it - not me)
Best I ever saw was someone's sig on usenet that was a couple of lines of ob-C that generated the mandlebrot set. it was freaking cool:
~~~~~~~~~~~~~}}}}}}}}}}}}}}}}}}}}||||||||{{{zyvrwuW{|||||}}}}}}~~~~~~~~~~~~
~~~~~~~~~~}}}}}}}}}}}}}}}}}}}}|||||||||{{{zyxwoaqwxz{{{|||||}}}}}}~~~~~~~~~
~~~~~~~~}}}}}}}}}}}}}}}}}}}|||||||||{{zzzyxvn Knwyz{{{{||||}}}}}}~~~~~~~
~~~~~~}}}}}}}}}}}}}}}}}}||||||||{{zyxuxxxwvuq svwwyzzzyr{||}}}}}}}~~~~~
~~~~}}}}}}}}}}}}}}}}}|||||{{{{{zzzxt> qf pttfqeqz{|}}}}}}}}~~~
~~~}}}}}}}}}}}}}}|||{{{{{{{{{zzzywotn atyz{||}}}}}}}}~~
~~}}}}}}}}}||||{{zwvyyyyyyyyyyyxvsP swvz{||}}}}}}}}~
~}}}}|||||||{{{{zyxvpN[ur]spvwwvi qxz{|||}}}}}}}}
~}||||||||{{{{{zyytun qq avz{|||}}}}}}}}
~||||||{zzzzyyxtroqb a xz{{|||}}}}}}}}
~@G::# 6# ( pvxyz{{||||}}}}}}}
~||||||{zzzzyyxtroqb a xz{{|||}}}}}}}}
~}||||||||{{{{{zyytun qq avz{|||}}}}}}}}
~}}}}|||||||{{{{zyxvpN[ur]spvwwvi qxz{|||}}}}}}}}
~~}}}}}}}}}||||{{zwvyyyyyyyyyyyxvsP swvz{||}}}}}}}}~
~~~}}}}}}}}}}}}}}|||{{{{{{{{{zzzywotn atyz{||}}}}}}}}~~
~~~~}}}}}}}}}}}}}}}}}|||||{{{{{zzzxt> qf pttfqeqz{|}}}}}}}}~~~
~~~~~~}}}}}}}}}}}}}}}}}}||||||||{{zyxuxxxwvuq svwwyzzzyr{||}}}}}}}~~~~~
~~~~~~~~}}}}}}}}}}}}}}}}}}}|||||||||{{zzzyxvn Knwyz{{{{||||}}}}}}~~~~~~~
~~~~~~~~~~}}}}}}}}}}}}}}}}}}}}|||||||||{{{zyxwoaqwxz{{{|||||}}}}}}~~~~~~~~~
~~~~~~~~~~~~~}}}}}}}}}}}}}}}}}}}}||||||||{{{zyvrwuW{|||||}}}}}}~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~}}}}}}}}}}}}}}}}}}}}}|||||{zmt{{{||||}}}}}~~~~~~~~~~~~~~~~
Source that does it:
main(){float A,B,P,Q,X,Y,d;int i,D=80,n=3120;for(X=-2.,Y=-1.5,d=6./D;B=2*A
*B+Y,A=P-Q+X,n;((P=A*A)+(Q=B*B)>4||++i>D)&&putchar(*((n--%D?X+=d/2,i<D?i%11
:11:(X=-2.0,Y+=d,12))+"Mandelbrot! \n"))&&(A=B=P=Q=i=0));}
//For each inventory that is a sofa and has a comfortclass, test sleeping in it, and if you like it save it to the wishList.
wishList = inventories.match({type: "Sofa", comfortClass: required}).forEach(testSleepInObjectFunction);
Elegant, eigh? Soon it's gonna be possible in C# too!!!
Console.WriteLine("Hello World!");
It ensures that your system is set up properly and ready for any programming action!
Truncate Table
One line of SQL can do so much damage to data that would take many programs hundreds of lines of code.
When I used ASP classic a lot, I was always frustrated that there was no floor/ceiling functions available. int
works for floor, but there was no built-in ceiling, until I somehow, somewhere, I figured this out:
ceilOfX = -int -x
I always thought that was an elegant one-liner.
if (this == null) return;
I tend to see some kind of poetry in that line. (I've actually ran across it)
I've always found interesting how IBM i RPG declares its files:
FSOMEFILE UF A E K Disk UsrOpn Commit
Declares the externally described disk file SOMEFILE for Input/Update/Write with keyed access, user-controlled open and commitment control.