text:
Calculate hamming weight with low hamming weight
Create a program that computes the hamming weight of a string. Winner is the program with the lowest hamming weight.
Rules:

Hamming weight for an ASCII character is defined as the total number of bits set to 1 in its binary representation.
Assume input encoding is 7-bit ASCII, passed through whatever input mechanism is normal for your language (e.g. stdin, args, etc.)
Output the result, as a number, to stdout or whatever default/normal output mechanism your language uses.
It should go without saying, but you have to be able to actually run the program, in real life, for it to be a valid solution.
Winner is the solution whose code has the lowest hamming weight.
Sorry, no solutions in whitespace for this one! Ok, you can code in whitespace now I've sorted out the rules :)

Per-character examples:
char |  binary  | weight
-----+----------+-------
a    | 01100001 | 3
x    | 01111000 | 4
?    | 00111111 | 6
\x00 | 00000000 | 0
\x7F | 01111111 | 7

if we take 0x20/ASCII 32 as the reference, isn't the humming weight of hello world 10 rather than 11?

Why is the weight of hello world 11? Only 10 characters are different from a space. Also  - a program's Hamming weight seems to be just its length, excluding spaces. Not so different from normal code golf.

Sorry, I totally screwed this up. Wikipedia's hamming weight article is rather misleading, and I totally fubar'ed the rules. Re-writing now. Update: Ok, re-written to define it as the number of bits set to 1 in the ASCII string, sorry for the screw-up.

@ugoren A solution with lower-value ASCII characters has a lower hamming weight.

Now it all makes sense. USE UPPERCASE, BEWARE OF ~ AND o.

@ugoren Yup, pretty much. TEST has a weight of 13, whereas test has a weight of 17.

So Hamming weight of a string is the sum of the Hamming weights of the characters, or is it the number of unique bits set?

@userunknown Sum of the Hamming weights of the characters.

@Polynomial Now that you've corrected the measurement of the Hamming weight, will you be lifting the ban on Whitespace?

@breadbox Good idea, though I can't imagine solutions would be particularly competitive ;)

Tip: Name your variables A, B, D, H, or P.

J (33)
One lower than 34!
+/,#:3 u:

Heavily inspired by this answer, but a hamming weight of one lower.
   +/,#:3 u:'+/,#:3 u:'
33

J, weight 34
+/,#:a.i.

Usage - place the string to be measured in quotes at the end:
   +/,#:a.i.'+/,#:a.i.'
34

Alternatively, taking input from the keyboard (weight 54):
   +/,#:a.i.1!:1[1
hello
21

There's only one way to write this :)

There isn't... I found a solution that has a hamming weight of one lower.

Not trying to be a buzzkill, but the rules ask for a program, not a fragment.

J, 39
+/,#:a.i:]

This is a function taking one argument.  (Or replace ] with the  string directly; as Gareth notes, that brings the cost down to 34.)

   +/,#:a.i:] 'hello world'
45
   +/,#:a.i:] '+/,#:a.i:]'
39

Great minds think alike. :-)

Python, 189
print sum(bin(ord(A)).count("1")for A in raw_input())

The Python 3 equivalent, print(sum(bin(ord(A)).count('1')for A in input())), has a score of 180.

@dan04: Use double quotes instead of single for 176.

QBasic, 322 311 286 264
H$=COMMAND$
FOR A=1 TO LEN(H$)
B=ASC(MID$(H$,A,1))
WHILE B>0
D=D+B MOD 2
B=B\2
WEND
NEXT
?D

Kind of the right tool for the job, still sucks of course.

+1 for using one of my favourite languages of all time. It's the first language I learnt to code in on a PC.

Unary 0
You all knew it was coming. First the BrainFuck program:
,[[>++[>>+>+<<<-]>>>
[<<<+>>>-]>>[-]<<<<<<[>>>>+>>+<<<<<<-]>>>>>>
[<<<<<<+>>>>>>-]<<<[>>+>+<<<-]>>>[<<<+>>>-]
[-]<<[>>[-]<[>[-]+<[-]]<[-]]>[-]>[<<<<<<->>>->>>
[-]<<<<<<[>>>>+>>+<<<<<<-]>>>>>>[<<<<<<+>>>>>>-]<<<
[>>+>+<<<-]>>>[<<<+>>>-][-]<<[>>[-]<[>[-]+<[-]]<[-]]>[-]>]<<<<<<
[>>+<[>>+>+<<<-]>>>[<<<+>>>-]>>[-]<<<<<<[>>>>+>>+<<<<<<-]>>>>>>
[<<<<<<+>>>>>>-]<<<[>>+>+<<<-]>>>[<<<+>>>-][-]<<[>>[-]<[>[-]+<[-]]<[-]]>
[-]>[<<<<<<->>>->>>[-]<<<<<<[>>>>+>>+<<<<<<-]>>>>>>[<<<<<<+>>>>>>-]<<<
[>>+>+<<<-]>>>[<<<+>>>-][-]<<[>>[-]<[>[-]+<[-]]<[-]]>[-]>]<<<<<<]>>>
[>+>+<<-]>>[<<+>>-][-]+<[>[-]<<[<<->>-]<<[>>+<<-]>>>[-]]>[<<<+<[-]>>>>
[-]]<<[->>>>+<<<<]<[-<<+>>]<<],]>>>>>>>.

I added newlines to make it "readable" but it has a Hamming weight of 4066. It works by repeatedly getting the quotient/remainders of an input string and adding up all the remainders. Of course should you run it  on itself you get: 226 (4066 % 256) (technically \xe2) so clearly it rules itself the winner.
Now we convert it to Unary and get
000 ... 9*google^5.9 0's ... 000

We use a unary implementation with NULL characters \x00 for '0' and boom, hamming weight of 0.
Bonus question:
For what ASCII characters c can you run this program on a string consisting on N repitions and have it output that character. (E.G. a string of 32 spaces gives a space). What values of N work (either an infinite number of them will work, or none will).

I'm not sure I understand this solution. The brainfuck program has a huge hamming weight. Does Unary accept null bytes as a program, or would you need to re-implement Unary? If it's the latter, it's not really a valid solution - anyone could just say "I define a programming language where any single input byte gives {result}", and win every code golf challenge on the site.

A null character Unary would be fine. All you need is an EOF to say stop counting. In fact here's some pseudo-C to read that file: main(){ bignum Unarynum = 0; int c; while(EOF!=(c=readchar())){ Unarynum++; } return Unarynum; } Doesn't matter at all what you choose to be your Unary char (as long as it isn't EOF).

I'm still not convinced it's the former category, rather than the latter.

Well here's a unary to C compiler that works fine with null characters: http://ideone.com/MIvAg. Of course the file required to make this program would not fit in the universe, but we have the capacity to run it.

If you can't actually run it, it's not really a solution.

As Carl Sagan once said: "If you wish to calculate the hamming weight of a string, you must first invent 10^500 universes." (billions and billions, even)

Golfscript 84 72 58
{2base~}%{+}*

(thanks to Howard and Peter Taylor for their help)
Input: the input string has to be on the stack (passed as command line argument, or simply placed on the stack).
In case you run it from the command line, make sure you use echo -n, otherwise the trailing newline will also be counted.
Output: prints the hamming weight value to the console
The program can be tested here.

Is Golfscript case-sensitive? If not, you can save a few bits by using BASE instead of base. Update: Just checked, BASE doesn't work. Good solution :)

@Polynomial I tried that after seeing your TEST/test comment :) But it doesn't work.

You can get rid of {...}2* by applying 2base~ in the first place. Gets score down to 72.

@Howard thanks for this great tip! I've applied it in my answer.

Your test mechanism is wrong, because you've forgotten an important limitation of your Web GolfScript page. You should have a ; before the string which you substitute for stdin, so that (; is unnecessary. Then Howard's observation gets it down to 65.

And then down to 58 using % instead of /].

@PeterTaylor thanks for pointing that out; I also ran it from the commandline and it works fine

C, weight 322 263 256
Does the hamming weight of the hamming weight count?
main(D,H,A)char*A,**H;{for(A=*++H;*A;A+=!(*A/=2))D+=*A%2;printf("%d",D-2);}

Used mostly standard golfing techniques.
A single loop calculates weight (shifting right and adding until zero) and scans the string (advances pointer when zero reached).
Assuming D is initialized to 2 (single parameter).
Hamming weight specific optimizations:
1. ABDH, with weight 2 each, used for names.
2. *++H preferred over H[1].

Hah, I utterly failed to understand your first sentence until just now.

You can get the score down to 230 by outputting the result as an unary number: main(D,H,A)char*A,**H;{for(A=*++H;*A;A+=!(*A/=2))if(*A%2)printf("@");}

@schnaader, I never knew @ was a digit in the unary system. I thought it only uses 0..0. But if you want to go this, way, printf("@"+*a%2) is shorter.

@ugoren: Depends on the convention/definition of unary. E.g. http://en.wikipedia.org/wiki/Unary_numeral_system does use tally marks and says "There is no explicit symbol representing zero in unary as there is in other traditional bases".

@schnaader, OK, but I think it's stretching the requirement "as a number" too far.

Perl, 80 (22 chars)
Done and done:
perl -0777nE 'say unpack"%32B*"'

Or here's an alternate version with a weight of 77 (21 chars):
perl -0777pE '$_=unpack"%32B*"'

I don't like that version as much, though, because its output omits the final newline.
To calculate the weight, I'm assuming that I'm counting characters in the usual way (excluding the perl -e/-E, but including other option characters). If for some reason people complain about this, then the best I can do without options is 90 (26 chars):
$/=$,,say unpack"%32B*",<>

Sample usage:
$ perl -0777nE 'say unpack"%32b*"' rickroll.txt
7071

Boom.

Pyth - 15
Disclaimer: This answer isn't eligible to win since Pyth is younger than this challenge.
Uses .B for binary representation and counts the number of "1"'s.
/.BQ\1

Takes input in a string to save on z versus Q.
Try it online here.

Scala 231
readLine().map(_.toInt.toBinaryString).flatten.map(_.toInt-48)sum

Selftesting code:
"""readLine().map(_.toInt.toBinaryString).flatten.map(_.toInt-48)sum""".map(_.toInt.toBinaryString).flatten.map(_.toInt-48)sum

with selftesting modification.

It's weight 495, not 231. You can't get weight 231 with 126 chars - that's an average of less than 2, and all printable chars (except @ and space, which you don't use) have weight 2 at least.

@ugoren: But it's only 65 chars. The program is printed nearly twice: Once the code to calculate the hamming weight, and a second time as static input to calculate it for the program. But the calculating part is missing the "readLine()" in front, because it takes the literal input. I tried to clarify the answer itself.

Java, weight 931 774 499 454
I think this is the only answer at the moment with a weight over about 300.
class H{public static void main(String[]A){System.out.print(new java.math.BigInteger(A[0].getBytes()).bitCount());}}

Expects input as a command line argument.

GNU sed -r, 467 + 1
(+1 for use of -r - or should that be +4?)
Outputs as a unary value per source line; to convert to a decimal total, redirect output into | tr -d "\n" | wc -c.  Counts all printable ASCII characters (32-126), plus linefeed (10).
s@[a-z]@\U& @g
s@[?{}~]@      @g
s@[][/7;=>OW|^]@     @g
s@[-'+.3569:<GKMNSUVYZ\\]@    @g
s@[#%&)*,CEFIJL1248ORTX]@   @g
s@$|[!"$(ABDH0P`]@  @g
y! @!11!

It's hard to avoid listing all characters, but we can reduce this observing that lowercase letters have a Hamming weight of one more than the corresponding uppercase letters.  We prefer newline (score 2) over semicolon (score 5) as a statement separator; we prefer @ (score 1) or ! (score 2) over / (score 5) as pattern delimiter.
Note - to get the right sets of characters, I created this table from the one in man ascii, sorted by weight.  Just add the scores right and below to get the overall weight of each character:
   2 4   3 5 6   7
   ---  ------   -
0:   @   0 P `   p |0

1: ! A   1 Q a   q |
2: " B   2 R b   r |1
4: $ D   4 T d   t |
8: ( H   8 X h   x |

3: # C   3 S c   s |
5: % E   5 U e   u |
6: & F   6 V f   v |2
9: ) I   9 Y i   y |
A: * J   : Z j   z |
C: , L   < \ l   | |

7: ´ G   7 W g   w |
B: + K   ; [ k   { |3
D: - M   = ] m   } |
E: . N   > ^ n   ~ |

F: / O   ? _ o     |4
   ---  ------   -
    1      2     3

This might prove useful to others.

Julia 262 268
Modified version uses handy 'count_ones' function for a saving of 6 (262)
show(mapreduce(x->count_ones(x),+,map(x->int(x),collect(ARGS[1]))))

Old version using no built in one-counting function (268)
show(mapreduce(x->int(x)-48,+,mapreduce(x->bits(x),*,collect(ARGS[1]))))

Uses command line argument for input.

CJam 52 or 48
If input is not already on the stack (52)
q:i2fbs:s:i:+

If input is on stack (48)
:i2fbs:s:i:+

For example
"Hello World":i2fbs:s:i:+

Julia, HW 199
H=mapreduce;H(B->B=='1',+,H(P->bits(P),*,collect(A[:])))

With
A="H=mapreduce;H(B->B=='1',+,H(P->bits(P),*,collect(A[:])))"

or by directly inserting the string:
julia> H=mapreduce;H(B->B=='1',+,H(P->bits(P),*,collect("H=mapreduce;H(B->B=='1',+,H(P->bits(P),*,collect(A[:])))")))
199

The ungolfed version (HW 411) looks like this:
bitstring=mapreduce(x->bits(x),*,collect(teststring[:]))
mapreduce(checkbit->checkbit=='1',+,bitstring)

And for the fun of it, here is an optimized version (Hamming Weight 231) of bakerg’s take on the problem:
A=mapreduce;show(A(B->int(B)-48,+,A(B->bits(B),*,collect(H[:]))))

with
H="A=mapreduce;show(A(B->int(B)-48,+,A(B->bits(B),*,collect(H[:]))))"

HPPPL (HP Prime Programming Language), 74
sum(hamdist(ASC(a),0))

The HP Prime graphing calculator has a built-in hamdist() function. The hamming weight of each character is the same as the hamming distance from 0.
ASC(string) creates an array of the ASCII values of each character in a string.
hamdist(value,0) computes the hamming distance from 0 for each ASCII value
sum() sums up all values.
Calculating the hamming weight of its own source code:

05AB1E, weight 17 (4 bytes)
ÇbSO

Try it online or verify some more test cases.
Explanation:
Ç       # Convert the characters in the (implicit) input to their ASCII decimal values
        #  i.e. "Test" → [84,101,115,116]
 b      # Convert those values to binary
        #  i.e. [84,101,115,116] → ["1010100","1100101","1110011","1110100"]
  S     # Split it into a list of 0s and 1s (implicitly flattens)
        #  i.e. ["1010100","1100101","1110011","1110100"]
        #   → [1,0,1,0,1,0,0,1,1,0,0,1,0,1,1,1,1,0,0,1,1,1,1,1,0,1,0,0]
   O    # Sum those (and output implicitly)
        #  i.e. [1,0,1,0,1,0,0,1,1,0,0,1,0,1,1,1,1,0,0,1,1,1,1,1,0,1,0,0] → 16

Perl 6, 102
+*.ords>>.base(2).comb(~1)

Try it online!
While this isn't code golf, the shortest solution also seems to have the smallest hamming weight...


text:
Code Golf of Death
Write some code that causes a BSOD or kernel panic!
Rules:

On Windows, you must cause a BugCheck (Blue Screen of Death), on Linux (or other *nix systems) you must cause a kernel panic.
Must not damage the system (i.e. it should work on reboot)
Kernel-mode drivers are allowed.
State your OS and version information.
Explain how the crash is caused.
It's not against the rules to use tools that are specifically designed to cause a crash, but doing so isn't very creative!
Highest upvotes wins.

Kernel mode drivers are allowed? Doesn't it make 1/0 a valid answer?

@urogen - Last time I checked, putting 1/0 in a file called driver.c doesn't constitute a valid kernel-mode driver. Regardless, the winner is based on upvotes, not code length.

Trying to say that using kernel drivers makes it uninteresting. Every crash in a driver crashes the kernel, and writing code that crashes isn't a challenge for most of us.

@ugoren - Sure, but a generic kernel driver crash won't get many upvotes, so it's unlikely to win. If you can make the system crash due to some strange or obscure trick in kernel-mode, that's likely to win you some votes.

I haven't been following Meta Code Golf lately - is "highest-upvoted" now allowed? (If this is the case, this website just got 100x more awesome!)

@minitech It's an objective criteria, so I don't see why it shouldn't be allowed.

I'm voting to close this question as off-topic because questions without objective winning criteria are off-topic

@cat See my reply to minitech's now-deleted comment.

@Polynomial this was on-topic when it was asked, and when it was asked(and up until a few months ago) "most votes" was objective. this is no longer the case: http://meta.codegolf.stackexchange.com/a/8134/46231

@Polynomial you will find this has been closed by community consensus, but you are free to appeal this closure on meta or by voting to reopen.

@cat Doesn't really matter now anyway. It got plenty of answers.

@Polynomial I've upvoted it and almost all of the answers, they're great and the community genuinely wish these sorts of challenges could be allowed, but that doesn't fit with the SE model.

@cat I don't think this question is lacking objective criteria. I think the bigger problem with this question is that it's about potentially harmful code. Granted, none of the code is malicious but it's still harmful.

@DrGreenEggsandHamDJ Well, my intention was certainly not harmful. I work in security, so if I wanted to write my own malicious code, I would!

@DrGreenEggsandHamDJ Indeed, the top answer is potentially harmful, but if you read the thingy I linked, there's a consensus that votes isn't objective, because people aren't.

@cat If you look through here and here you'll see that nowhere is it explicitly stated that popularity contests are off-topic. They're discouraged because they tend to be off-topic, but they aren't inherently off-topic. I think this question (harmful code aside) is very high-quality as far as popcons go.

@DrGreenEggsandHamDJ You are correct in all you say. popcons themselves are not inherently off-topic, it's just that popcons are off-topic when the provided primary winning criterion is not an objective one.

@cat In every popcon, the primary winning criteria is votes. Granted, saying "Most votes wins" doesn't necessarily make it a high quality challenge. How is this challenge more objective than this challenge, when they are both scored by votes?

@DrGreenEggsandHamDJ That question is special primarily because it's not a challenge by any sense of the word. It's not objective; the winner is M. Buettner's Mathematica because it's a damn amazing answer. Helka, being a well-known great-challenge-writer thought that might be an interesting experiment but we can only ever have one of those.

@DrGreenEggsandHamDJ So if the code is potentially harmful, disregarding its validity as a popcon, why does this have 4 reopen votes? That's kinda scary since this definitely shouldn't stay open in a self-respecting graduated PPCG

@cat I don't know. Although I still disagree with your opinion on this questions validity as a popcon. This comment chain is getting a little long. We should probably take it to chat or meta. (Or maybe even both)

Let us continue this discussion in chat.

I'm voting to close this question as off-topic because it requires malicious code, which violates our rules.
http://meta.codegolf.stackexchange.com/a/4831/34718

BSOD in 3 key presses: http://www.howtogeek.com/howto/windows-vista/keyboard-ninja-kill-windows-with-the-blue-screen-of-death-in-3-keystrokes/

Bash, x86 Linux 2.6.20 kernel
Warning: the following command may cause permanent damage to your system.
cat /dev/urandom > /dev/mem

Will output the following (try here).
After this, the script hangs.
/var/root # cat /dev/urandom > /dev/mem
BUG: unable to handle kernel paging request at virtual address 474e82a5
 printing eip:
c01450c4
*pde = 00000000
Oops: 0000 [#1]
CPU:    0
EIP:    0060:[<c01450c4>]    Not tainted VLI
EFLAGS: 00000082   (2.6.20 #12)
EIP is at free_block+0x54/0xf0
eax: 00000000   ebx: 474e82a1   ecx: c00745c8   edx: c0005e80
esi: c0070ce0   edi: c002c1a0   ebp: 00000000   esp: c0085eec
ds: 007b   es: 007b   ss: 0068
Process events/0 (pid: 3, ti=c0084000 task=c0094030 task.ti=c0084000)
Stack: c0076410 00000002 c0051db0 c0051db0 c0051da0 00000002 c002c1a0 c01457dd
       00000000 c0070ce0 c002c1a0 c0091840 c0145800 c0145870 00000000 00000000
       c02cb2a0 c02cb2a0 00000296 c011dd27 c003fab0 c0094030 c009413c 00047e6c
Call Trace:
 [<c01457dd>] drain_array+0x7d/0xa0
 [<c0145800>] cache_reap+0x0/0x110
 [<c0145870>] cache_reap+0x70/0x110
 [<c011dd27>] run_workqueue+0x67/0x130
 [<c011df17>] worker_thread+0x127/0x140
 [<c010c7d0>] default_wake_function+0x0/0x10
 [<c010c817>] __wake_up_common+0x37/0x70
 [<c010c7d0>] default_wake_function+0x0/0x10
 [<c011ddf0>] worker_thread+0x0/0x140
 [<c0120d94>] kthread+0x94/0xc0
 [<c0120d00>] kthread+0x0/0xc0
 [<c0102ee7>] kernel_thread_helper+0x7/0x10
 =======================
Code: 04 0f 8d 8f 00 00 00 8b 44 24 08 8b 0c a8 8d 91 00 00 00 40 c1 ea 0c c1 e2

Here is another exception found with the same command:
/dev # cat urandom > mem
------------[ cut here ]------------
Kernel BUG at c014514c [verbose debug info unavailable]
invalid opcode: 0000 [#1]
CPU:    0
EIP:    0060:[<c014514c>]    Not tainted VLI
EFLAGS: 00000046   (2.6.20 #12)
EIP is at free_block+0xdc/0xf0
eax: 1608347b   ebx: c009b010   ecx: c003f508   edx: c00057e0
esi: c009b000   edi: c002cd40   ebp: 00000000   esp: c0085eec
ds: 007b   es: 007b   ss: 0068
Process events/0 (pid: 3, ti=c0084000 task=c0094030 task.ti=c0084000)
Stack: c009b010 00000004 c009b010 c009b010 c009b000 00000004 c002cd40 c01457dd
       00000000 c02ddf20 c002cd40 c0091840 c0145800 c0145870 00000000 00000000
       c02cb2a0 c02cb2a0 00000296 c011dd27 c005c5a0 c0094030 c009413c 000409ed

Very nice! Rather surprised that it's so easy to trash /dev/mem like that, though... wouldn't that imply that kernel memory can be altered by any process running as root?

I guess so. With great power comes great responsibility.

Well, armed with this bit of fun information, I'm going to dump my machine's memory and dig around in it! :)

Both bugs are the same, by the way. You're just in /dev in the second one. You can also crash it with cat /dev/mem > /dev/mem, though I'm not sure why that dies.

Violates the Must not damage the system requirement - if you run it enough times, it will eventually rewrite the disk driver with code that formats the disk.

Yeah, I realized that. What I actually meant is that another kind of exception was triggered (Invalid opcode in the second case, Page fault in the first).

@ugoren That is an extremely unlikely scenario. It would have to write a bunch of accurate 32 bit addresses and instructions at the right place and not overwrite others

I tried /dev/zero instead of /dev/urandom, but it seems to just spin the CPU instead of causing a panic.  Probably something got stuck in a loop.

" run it enough times, it will eventually rewrite the disk driver with code that formats the disk" - Not certain, urandom is pseudorandom.

@ugoren The "must not damage the system" rule is just to prevent answers like sudo rm -Rf /. The chances of causing permanent damage to the system using this method are less than the chances of, say, brute-forcing the output of a set of song lyrics based on the hash of the text.

Another trick of a similar kind is dd if=/dev/zero of=/dev/mem count=9k.

For me, this outputs bash: /dev/mem: Permission denied when using sudo, and cat: write error: Bad address when using su.

@LegionMammal978 are you root? (you need to log in as root.)

Got a null pointer dereference ;-)

C, 16 chars, for P5 x86
main=-926478352;

Remember the F00F bug everyone? I helped lock up a machine or two back in the day with this little program. (Yes, I've been golfing for that long.)
Granted, it's not quite what was asked for, and it only works on old steppings of the P5 Pentium chips. But in its favor, it's cross-platform, working on both Linux and Windows!

It's malicious, Isn't it?

QBASIC, 38 Characters
DEF SEG=0:FOR I=0 TO 4^8:POKE I,1:NEXT

Not sure how you would define a BSOD or Kernel panic in DOS, but this is probably pretty close. When run the screen just goes blank, and the machine responds to nothing, not even Ctrl+Alt+Delete.  You have to restart with a hard reset or power cycle to get the machine going again. This is running on DOS 6.22 under VirtualBox.  Not sure exactly why it causes the system to crash, but, basically the program is writing (POKE) to memory that it has no business writing to.

The reason it crashes is because you're overwriting system program memory with junk.

Yeah, I knew that, but I was thinking something a little more specific. I'm not even sure what part of memory it's writing to.

You're overwriting the DOS interrupt vectors and COMMAND.COM program code stored in low memory addresses. Source: http://img.tfd.com/cde/MEMMAP.GIF

sh (in JSLinux)
Linux gives the init process special protection against signals. However, I noticed that in JSLinux, /sbin/init is a shell script that executes other binaries (most symlinked to /bin/busybox).
This "infinite" while loop restarts sh as necessary:
while /bin/true; do

  setsid sh -c 'exec sh </dev/ttyS0 >/dev/ttyS0 2>&1'

done

However, what if /bin/true does not always return an exit code of 0? /bin is on the read-only root file system, yet Linux lets us change that using "bind" mounts:
cp -R /bin /tmp/boom
rm /tmp/boom/true
printf '#!/bin/sh\nexec [ $PPID != 1 ]' > /tmp/boom/true
chmod 755 /tmp/boom/true
mount -o bind /tmp/boom /bin
killall -9 sh

And we get:
/var/root # ./boom.sh
Killed
Kernel panic - not syncing: Attempted to kill init!

Bash on Linux, 27 chars
echo c>/proc/sysrq-trigger

Or if you have sudo permissions:
echo c|sudo tee /proc/sysrq-trigger

This results in sh: can't create /proc/sysrq-trigger: nonexistent directory for me. (though this is in jsLinux, so I should probably test on a real box)

GTB, 13 characters
Executed from a TI-84 calculator
:"+"→_[_+_→_]

If most of the RAM is free, it will crash with ERR:MEMORY
Otherwise, the calculator's RAM is so clogged that it turns off and clears it besides.

 Great example of a "calculator virus"

I see, this just puts +, ++, ++++, etc. in Str0. It gave me ERR:MEMORY, but trying to display Str0's value instantly crashed my 84+. Also, this made me lose all of my programs.

Batch (Windows 98)
\con\con

This is actually a BSOD Easter Egg of Windows 98...

yessssssssssss!

:(){ :|:& };:

In bash shell,
I am not so sure if this counts here, but if you let it run long enough CPU overheats and system crashes, and it does reboots safely without harm, of course if you do it all the time there will be some system damage.

This doesn't really work. It just spins the CPU at 100% usage, which is negated by any half-decent cooling system. I've ran Folding@Home for months at 100% CPU usage and never had the machine even stutter.

Its a fork bomb

@Polynomial I really didn't knew what 'kernel panic' meant so should I remove my answer? (luckily I haven't seen one yet, but I only switched to linux an year back, I have seen a lot of BSODs almost 7-8 times a month on 'XP', less so often on '7' but still noticeable. I think the shortest solution would be a windows one)

@Optimus You might as well leave it here - it's not a valid answer, but it's not doing any harm. I'd actually expect a Windows solution to be more difficult, since Linux allows you to break things if you really want to.

@Polynomial I don't think that's true, Linux only better documents the ways you can break it.

@leftaroundabout I disagree. Windows is designed from the ground up to actively prevent you from damaging the system state from user-mode, and also stops you from modifying critical system files via Windows File Protection, locked system files, etc. Linux, on the other hand, is designed in a way that allows for maximum stability if you don't try to mess with it. But, if you do want to mess with it, you can. For example, I can modify /dev/mem or /dev/kmem as I wish from root.

@Optimus I've seen :(){ :|:& };: a few times... I'm curious to know how this works? @PrinceJohnWesley mentioned this is a "fork bomb"?

@WallyWest it defines a function named : , read it as bomb() { bomb|bomb& }; bomb, so u define a function bomb and call it once. but this function creates two copies of itself, piping one's output to other and & creates a separate thread/process/fork or something, so basically it exponentially creates a lot of processes occupying all of the memory until the system comes to a halt. everything should be ok after reboot unless you have a forkbomb in your startup. if its not run as root and user memory restrictions are in place, it won't be able to halt your system.

Ruby (run as root), 36 or 40 chars (depending on matches for /p*/s*r)
See http://www.kernel.org/doc/Documentation/sysrq.txt and search for 'c' (including quotes!) to see why it works.
open(Dir['/p*/s*r'][0],?a){|f|f<<?c}

EDIT: Longer version that works if you have other things matching /p*/s*r
open('/proc/sysrq-trigger',?a){|f|f<<?c}

EDIT 2: Intentionally overkill.

get-process | stop-process -force

in powershell

"It's not against the rules to use tools that are specifically designed to cause a crash, but doing so isn't very creative!"

Linux bash
cat /dev/zero > /dev/mem

Clear the entire memory and cause a infinite kernel panic.
Try it here.

How different is this from this? s/zero/urandom/.

@NoOneIsHere The kernel panic never stop with this version, and here the memory is cleared, not filled with random bytes.

Batch, 15 bytes
:A
start
goto A

Merely overflows the memory in linear time by starting up cmd.exe hundreds and hundreds and hundreds and hundreds and hundreds and hundreds and hundreds and hundreds and hundreds and hundreds and hundreds and hundreds and hundreds and hundreds and hundreds and hundreds and hundreds and hundreds and hundreds and hundreds and hundreds and hundreds and hundreds and hundreds and hundreds and hundreds of times.
There's a deadlier (but probably non-competing) 24-byte program that starts up itself over and over again, thus overflowing the memory in logarithmic time (i.e upgrading your RAM doesn't delay the crash). Suppose the below code is located in C:\a.bat:
:A
start C:\a.bat
goto A

.
Honestly I'm afraid to try those out.

Did anyone notice that the latter program is a fork bomb?

Yes, I did. :() { : | : & }; :

why not @0 instead of C:\a.bat?

source: Stack Exchange

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

sort: votes


text:
Detect the character encoding of the input
Your task is to golf a program that prints which character encoding, if any, the data read from the input represents. It should be able to detect the following encodings:

ASCII
ISO 8859-1
UTF-8
UTF-16

One of the above names of character encodings should be printed (in the same way) if it can be determined which is used. If the input is not ASCII, but it's ambiguous which of the other encodings is used, a ? should be printed. If none of the encodings can be valid, X must be printed.
Furthermore, the following should be taken into account:

If the input is valid ASCII, ASCII should be printed. Even though this means the other encodings are also valid. When the input is not ASCII, ? should printed in case of any ambiguity.
The UTF's are not required to start with a BOM.
UTF-16 can be either big or little endian. This means there are actually five different encodings to detect.
If UTF-8 or UTF-16 data encodes a number between 0 and 0x10FFFF you may consider it valid, even if it represents a Unicode code point that is technically not allowed in this encoding. Therefore you do not have to worry about unassigned code points and such.
ISO 8859-1 is considered invalid when any of its undefined bytes (positions 0-31 and 127-159, except 9, 10 and 13) are used.
This is code golf.

Happy golfing!

Needs test cases which give each possible output. In particular, I challenge you to provide a test case which is unambiguously UTF-8. You also need to specify how to handle a stream which could be ASCII or UTF-16.

Presumably the idea is to identify it as the most restrictive encoding that it adheres to. Thus, If a stream contains only 7-bit chars, it's ASCII. Otherwise, if the stream consists entirely of valid UTF-8 sequences, it's UTF-8. Otherwise, if it's a valid UTF-16LE or UTF-16BE sequence, then identify it as such. ISO 8859-1 is then the final fallback. The question I have is, is the program expected to recognize unassigned Unicode code points as a way to invalidate a stream? Or is it enough to just recognize if they're in the valid range? I certainly hope it's the latter.

@breadbox: you don't have to take unassigned code points into account, it should just be a valid range between U+000001 and 0x10FFFF. I disallowed NULL-characters to make it easier to distinguish between UTF-16 and the rest.

There are 16 cases. You have specified the output for 12 of them. None of your conditions match a string which is valid ASCII and valid UTF-16. I believe that 2 of the 4 unspecified cases are actually possible.

I'm sorry. You're correct. I made a stupid mistake: valid ASCII could indeed always be valid UTF-16 if there are an even number of characters (UTF-16 is usually not valid ASCII though). I will update the description accordingly and let ASCII take precedence over anything.

\n and \t aren't valid ISO 8859-1? I used them all the time!

My mistake: newline, tab and carriage return are defined, the rest in these ranges officially isn't.

All the control characters, 0-31 and 127-159, are defined. They are technically not part of ISO-8859-1, but it seems highly unrealistic to say that a stream that contains such codes cannot be a valid ISO 8859-1 stream.

Does it HAVE to be streamed from STDIN? Can it be read from a file? PHP is dooking out on me when trying to read binary from STDIN.

@jdstankosky I generalised 'stdin' to 'the input', so now you can read the input from whatever (sensical) source you want.

so you're basically askin for Linux command line toolfile: file -bi /path/to/file

I'm voting to close this question as unclear because it's hard to tell the requirements without unambiguous test cases, and there are none.

Tcl, 247
set i [read [open f rb]];foreach n\ d {ascii ASCII utf-8 UTF-8 unicode UTF-16 iso8859-1 ISO\ 8859-1} {if {[encoding convertt $n [encoding convertf $n $i]]eq$i&&($n!="iso8895-1"||[regexp {[\1-\10\13\14\16-\37\177-\237]} $i])} {puts $d;exit}};puts X

Reads the input from the file f in the current directory.
It works by decoding and re-encoding the input into the different charsets and check if the input and the re-encoded input is equal.
I believe that valid UTF-8 is also valid (but useless) ISO 8859-1, so I print UTF-8 then.

Scala, 505 bytes (w/o using built-in encoders)
def e(s:Array[Byte])=if(s.forall(_>0))"ASCII"else{var a=true;var b=true;var p=0;var q=false;var v=0;var t=false;for(c<-s){if(a){if(c== -64||c== -63||c> -12)a=false else{if(p==0)p=if(c>0)0 else if(c< -32)1 else if(c< -16)2 else 3 else a=c<= -64}};if(b){val x=(c+256)%256;if(q){v=v*256+x;if(v>55295&&v<56320)t= !t;b=t;if(v>56319&&v<57344)t= !t}else v=x}};b=b&& !t;val c=s.forall{x=>x==9||x==10||x==13||x>=32&&(x> -97)};if(a&&b||b&&c||a&&c)"?"else if(a)"UTF-8"else if(b)"UTF-16"else if(c)"ISO 8859-1"else"X"}

Unfortunately doesn't detect overlong encodings in UTF-8.

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


text:
Operations with Lists
Inspired by this question.
Given a list containing numbers, print:

The sum and product of the numbers in the list
The average and median
The differences between each term in the list (e.g. [1,2,3] -> [1,1]: 1+1=2, 2+1=3)
The list, sorted ascending
The minimum and maximum of the list
The standard deviation of the list

For reference:
Standard Deviation
$$\sigma=\sqrt{\frac1N\sum^N_{i=1}(x_i-\mu)^2}$$
Where \$\mu\$ is the mean average, \$x_i\$ is the \$i\$th term in the list, and \$N\$ is the length of the list.
Shortest code wins. Good luck!

Do we have to print them in that order?

Q, 41
{(+/;*/;avg;med;-':;asc;min;max;dev)@\:x}

'med'...facepalm

I was wondering what you were up to!

TI-BASIC, 41 bytes
1-Var Stats is one byte, and Σx, x̄, etc. are two bytes each.
Ans→L₁
1-Var Stats
SortA(L₁
Disp Σx,prod(Ans),x̄,Med,ΔList(Ans),L₁,minX,maxX,σx

If changing the output order is allowed, a close-paren can be saved, bringing the score to 40 bytes.

J, 73 70 characters
((+/;*/;a;(<.@-:@#{/:~);2&-~/\;/:~;<./;>./;%:@:(a@:*:@:(-a)))[a=.+/%#)

Usage:
   ((+/;*/;a;(<.@-:@#{/:~);2&-~/\;/:~;<./;>./;%:@:(a@:*:@:(-a)))[a=.+/%#)1 2 3 4
+--+--+---+-+-------+-------+-+-+-------+
|10|24|2.5|3|1 1 1 1|1 2 3 4|1|4|1.11803|
+--+--+---+-+-------+-------+-+-+-------+

It has to be 1 1 1 not 1 1 1 1 as difference itself next

Q (87 chars)
(sum;prd;avg;{.5*(sum/)x[((<)x)(neg(_)t;(_)neg t:.5*1-(#)x)]};(-':);asc;min;max;dev)@\:

eg.
q) (sum;prd;avg;{.5*(sum/)x[((<)x)(neg(_)t;(_)neg t:.5*1-(#)x)]};(-':);asc;min;max;dev)@\: 10 9 8 7 6 5 4 3 2 1
55
3628800
5.5
5.5
10 -1 -1 -1 -1 -1 -1 -1 -1 -1
`s#1 2 3 4 5 6 7 8 9 10
1
10
2.872281

Ruby 187
O=->l{g=l.size
r=l.sort
s=l.inject(:+)+0.0
m=s/g
p s,l.inject(:*),m,g%2>0?r[g/2]:(r[g/2]+r[g/2-1])/2.0,l.each_cons(2).map{|l|l[1]-l[0]},r,r[0],r[-1],(l.inject(0){|e,i|e+(i-m)**2}/g)**0.5}

Usage syntax: O[<array>] (for example, O[[1,2,3]])
Outputs all the required values to the console, in the order specified in the question.
IdeOne examples:

with odd number of elements: http://ideone.com/83ouj
with even number of elements: http://ideone.com/7PTRq

Julia 0.6, 66 bytes
x->map(f->f(x),[sum,prod,mean,median,diff,sort,extrema,std])|>show

Try it online!
Julia 0.6, 88 bytes (uncorrected std dev, as in op)
x->map(f->f(x),[sum,prod,mean,median,diff,sort,extrema,x->std(x,corrected=false)])|>show

Try it online!

this isn't right, because Julia is using the sample standard deviation calculation (dividing by n-1) rather than the population std (dividing by n) as required in the problem. Multiplying by (n-1)/n wouldn't fix it either, because when dividing by n-1, NaN is produced. I ran into the same problems when trying to do this in R and haven't given it thought since.

That didn't even occur to me. I added an alternate solution with the correct std deviation.

53 bytes / 71 bytes

Scala 208 202 188:
val w=l.size
val a=l.sum/w
val s=l.sortWith(_<_)
Seq(l.sum,l.product,a,s((w+1)/2),(0 to w-2).map(i=>l(i+1)-l(i)),s,l.min,l.max,(math.sqrt((l.map(x=>(a-x)*(a-x))).sum*1.0/w))).map(println)

Test:
scala> val l = util.Random.shuffle((1 to 6).map(p=>math.pow(2, p).toInt))
l: scala.collection.immutable.IndexedSeq[Int] = Vector(64, 8, 4, 32, 16, 2)

scala> val a=l.sum/l.size
a: Int = 21

scala> val s=l.sortWith(_<_)
s: scala.collection.immutable.IndexedSeq[Int] = Vector(2, 4, 8, 16, 32, 64)

scala> Seq(l.sum,l.product,a,s((s.size+1)/2),(0 to l.size-2).map(i=>l(i+1)-l(i)),l.sortWith(_<_),l.min,l.max,(math.sqrt((l.map(x=>(a-x)*(a-x))).sum*1.0/l.size))).map(println)
126
2097152
21
16
Vector(-56, -4, 28, -16, -14)
Vector(2, 4, 8, 16, 32, 64)
2
64
21.656407827707714

For me "Vector(-56, -4, 28, -16, -14)" is wrong

@RosLuP: Why is it wrong?

Yes you are right if input is "Vector(64, 8, 4, 32, 16, 2)" ( i confuse the input)

Jelly, 27 bytes
_ÆmÆḊ÷L½$
Wẋ9SPÆmÆṁIṢṂṀÇ9ƭ€

Try it online!
How it works
_ÆmÆḊ÷L½$ - Helper link. Takes a list l on the left
 Æm       - Yield the mean of l
_         - Subtract the mean from each element of l
   ÆḊ     - Calculate the norm
        $ - Run the previous two commands over l:
      L   -   Length of l
       ½  -   Square root
     ÷    - Divide the norm by the square root of l's length

Wẋ9SPÆmÆṁIṢṂṀÇ9ƭ€ - Main link. Takes a list l on the left
W                 - Yield [l]
 ẋ9               - Repeat 9 times
              9ƭ€ - Generate a 9 element list by running the previous 9 commands over l
                    and collecting the results together:
   S              -   Sum
    P             -   Product
     Æm           -   Mean
       Æṁ         -   Median
         I        -   Forward increments
          Ṣ       -   Sort
           Ṃ      -   Minimum
            Ṁ     -   Maximum
             Ç    -   Helper link (standard deviation)

Python 3.8, 174 167 148 147 bytes
-7 bytes thanks to @wasif
-19 bytes thanks to math.prod()
-1 bytes thanks to @The Fifth Marshal
lambda l:[sum(l),math.prod(l),mean(l),median(l),[m-n for n,m in zip(l,l[1:])],sorted(l),min(l),max(l),stdev(l)]
import math
from statistics import*

Try it online!

The code didn't work. Did you test it? Python doesn't have prod() and your forward differences calculation was wrong. I fixed it for you with 7 bytes saved

In PyCharm, math.prod works in Python 3.8. Maybe it is 3.8+ specific?

yes maybe. If that's the case you should add "3.8" to language name. But please also fix the forward differences calculation

math.prod indeed has been added in Python 3.8, so you might want to edit it back in again: https://docs.python.org/3.8/library/math.html#math.prod  BTW: the post does not match the tio linked code

-1 byte

C++14, 340 383 bytes
As generic unnamed lambda. First parameter L is the list as std::list of floating point type and second parameter is the desired output stream, like std::cout.
#import<cmath>
#define F(x);O<<x<<'\n';
#define Y l=k;++l!=L.end();
#define A auto
[](A L,A&O){A S=L;A l=L.begin(),k=l;A n=L.size();A s=*l,p=s,d=s*s,h=n/2.;for(S.sort(),Y s+=*l,p*=*l,d+=*l**l);for(l=S.begin();--h>0;++l)F(s)F(p)F(s/n)F(*l)for(Y)O<<*l-*k++<<","F(' ')for(A x:S)O<<x<<","F(' ')F(S.front())F(S.back())F(sqrt((d-s*s/n)/(n-1)))}

Compiles with a warning, C++ does not allow " directly followed by literals like F. Program still running.

-1 & -2 bytes thanks to  Zacharý

Ungolfed:
#include<iostream>
#include<list>

#import<cmath>
#define F(x);O<<x<<'\n';
#define Y l=k;++l!=L.end();
#define A auto

auto f=
[](A L, A&O){
  A S=L;                  //copy the list for later sorting
  A l=L.begin(),          //main iterator
    k=l;                  //sidekick iterator
  A n=L.size();
  A s=*l,                 //sum, init with head of list
    p=s,                  //product, same
    d=s*s,                //standard deviation, formula see https://en.wikipedia.org/wiki/Algebraic_formula_for_the_variance
    h=n/2.;               //for the median later
  for(
    S.sort(),             //now min/med/max is at known positions in S
    Y //l=k;++l!=L.end(); //skip the headitem-loop
    s += *l,              //l points the next element which is fine
    p *= *l,              //since the head given at definiten
    d += *l * *l          //needs the sum of the squares
  );
  for(
    l=S.begin();          //std::list has no random access
    --h>0;                //that's why single increment loop
    ++l                   //until median is crossed
  )
  F(s)  //;O<<s<<'\n';    //sum
  F(p)                    //product
  F(s/n)                  //average
  F(*l)                   //median (in S)
  for(Y) //l=k;++l!=L.end(); //set l back to L
    O<<*l-*k++<<","       //calc difference on the fly
  F(' ')
  for(A x:S)              //output sorted list
    O<<x<<","
  F(' ')
  F(S.front())            //minimum
  F(S.back())             //maximum
  F(sqrt((d-s*s/n)/(n-1))) //standard deviation
}

;

using namespace std;

int main() {
 list<double> l = {10,3,1,2,4};
 f(l, cout);
}

I think you can save a few bytes by changing F to ;F(x)O<<x<<'\n'; and the last line to: [](A L,A&O){A S=L;A l=L.begin(),k=l;A n=L.size();A s=*l,p=s,d=s*s,h=n/2.;for(S.sort(),Y s+=*l,p*=*l,d+=*l**l);for(l=S.begin();--h>0;++l)F(s)F(p)F(s/n)F(*l)for(Y)O<<*l-*k++<<","F(' ')for(A x:S)O<<x<<","F(' ')F(S.front())F(S.back())F(sqrt((d-s*s/n)/(n-1)));}

@Zacharý There was indeed an unnecessary ; quite at the end. That could be removed, but the compiler does not like " "F: warning: invalid suffix on literal; C++11 requires a space between literal and string macro it compiles though...

Does it work though?!

@Zacharý yes it does work.

327 bytes

Perl 5, 204 + 1 = 205 bytes
@L=sort{$a<=>$b}@F;$p=1;$s+=$_,$p*=$_,$a+=$_/@F for@L;for(0..$#F){$o=($F[$_]-$a)**2/@F;push@d,$F[$_]-$F[$_-1]if$_}$o=sqrt$o;$m=@F%2?$F[@F/2]:$F[@F/2]/2+$F[@F/2-1]/2;say"$s $p$/$a $m$/@d$/@L$/@L[0,-1]$/$o"

Try it online!

Factor + math.unicode, 90 bytes
[| s | s Σ s Π s mean s median s differences s [ > ] sort s minmax s population-std .s ]

Try it online!
Should be pretty self-explanatory, I hope. Factor has a built-in for each of these, but only a few have short aliases. While cleaving is cool, it's much shorter to go with locals here. Locals are also shorter than storing the words in a list and using [ execute ] with each on them, which would eventually catch up if the list had been re-used even more.

Pyt, 39 bytes
←ĐĐĐĐĐĐĐŞ⇹Ʃ3ȘΠ4Șµ5Ș₋⇹6Ș↕⇹7ȘṀ↔ĐĐµ-²Ʃ⇹Ł/√

This outputs, in order, the median, the product, the differences, the list reversed, the sum, the maximum and minimum, the mean, and the standard deviation.q
Try it online!
Explanation:
←ĐĐĐĐĐĐĐ                                              Push the array onto the stack 8 times
        ş                                             Sort in ascending order
         ⇹                                            Stack management
          Ʃ                                           Sum
           3Ș                                         Stack management
             Π                                        Product
              4Ș                                      Stack management
                µ                                     Mean (as a float)
                 5Ș                                   Stack management
                   ₋                                  Differences
                    ⇹6Ș                               Stack management
                       ↕                              Minimum and maximum
                        ⇹7Ș                           Stack management
                           Ṁ                          Median
                            ↔                         Stack management
                             ĐĐµ-²Ʃ⇹Ł/√               Standard Deviation

APL NARS, 119 chars, 182 bytes
{m←(s←+/w)÷n←⍴w←,⍵⋄s,(×/w),m,(n{j←⌊⍺÷2⋄2|⍺:⍵[1+j]⋄2÷⍨⍵[j]+⍵[j+1]}t),(⊂¯1↓(1⌽w)-w),(⊂t←w[⍋w]),(⌊/w),(⌈/w),√n÷⍨+/(w-m)*2}

test
  h←{m←(s←+/w)÷n←⍴w←,⍵⋄s,(×/w),m,(n{j←⌊⍺÷2⋄2|⍺:⍵[1+j]⋄2÷⍨⍵[j]+⍵[j+1]}t),(⊂¯1↓(1⌽w)-w),(⊂t←w[⍋w]),(⌊/w),(⌈/w),√n÷⍨+/(w-m)*2}
  ⎕fmt h 0
┌9──────────────────────┐
│        ┌0─┐ ┌1─┐      │
│0 0 0 0 │ 0│ │ 0│ 0 0 0│
│~ ~ ~ ~ └~─┘ └~─┘ ~ ~ ~2
└∊──────────────────────┘
  ⎕fmt h 3
┌9──────────────────────┐
│        ┌0─┐ ┌1─┐      │
│3 3 3 3 │ 0│ │ 3│ 3 3 0│
│~ ~ ~ ~ └~─┘ └~─┘ ~ ~ ~2
└∊──────────────────────┘
  ⎕fmt h 1 2 3
┌9───────────────────────────────────────┐
│        ┌2───┐ ┌3─────┐                 │
│6 6 2 2 │ 1 1│ │ 1 2 3│ 1 3 0.8164965809│
│~ ~ ~ ~ └~───┘ └~─────┘ ~ ~ ~~~~~~~~~~~~2
└∊───────────────────────────────────────┘
  ⎕fmt h 1 2 3 4
┌9────────────────────────────────────────────────┐
│              ┌3─────┐ ┌4───────┐                │
│10 24 2.5 2.5 │ 1 1 1│ │ 1 2 3 4│ 1 4 1.118033989│
│~~ ~~ ~~~ ~~~ └~─────┘ └~───────┘ ~ ~ ~~~~~~~~~~~2
└∊────────────────────────────────────────────────┘
  ⎕fmt h 1 2 7 3 4 5
┌9──────────────────────────────────────────────────────────────────┐
│                       ┌5──────────┐ ┌6───────────┐                │
│22 840 3.666666667 3.5 │ 1 5 ¯4 1 1│ │ 1 2 3 4 5 7│ 1 7 1.972026594│
│~~ ~~~ ~~~~~~~~~~~ ~~~ └~──────────┘ └~───────────┘ ~ ~ ~~~~~~~~~~~2
└∊──────────────────────────────────────────────────────────────────┘

Ocaml - 288 bytes
Assuming the given list is a non-empty list of floats (to avoid conversions), and that the returned median is the weak definition of the median :

median l = n such that half the elements of l are smaller or equal to n and half the elements of l are greater or equal to n

open List
let f=fold_left
let z=length
let s l=f(+.)0. l
let a l=(s l)/.(float_of_int(z l))let rec i=function|a::[]->[]|a::b->(hd b -. a)::(i b)let r l=let t=sort compare l in(s,f( *.)1. l,a t,nth t((z t)/2+(z t)mod 2-1),t,i l,nth t 0,nth t((z t)-1),sqrt(a(map(fun n->(n-.(a l))**2.)l)))

The readable version is
open List

let sum l = fold_left (+.) 0. l
let prod l = fold_left ( *. ) 1. l
let avg l = (sum l) /. (float_of_int (length l))
let med l =
        let center = (length l) / 2 + (length l) mod 2 -1 in
        nth l center
let max l = nth l 0
let min l = nth l ((length l) - 1)
let dev l =
let mean = avg l in
        sqrt (avg (map (fun n -> (n -. mean)**2.) l))

let rec dif =
        function
        | a::[] -> []
        | a::b -> ((hd b) - a) :: (dif b)

let result l =
        let sorted = sort compare l in
        (
                sum sorted,
                prod sorted,
                avg sorted,
                med sorted,
                sorted,
                dif l,
                max sorted,
                min sorted,
                dev sorted
        )

PHP, 213 bytes
function($a){echo$s=array_sum($a),_,array_product($a),_,$v=$s/$c=count($a);foreach($a as$i=>$x){$d+=($x-$v)**2;$i&&$f[]=$x-$a[$i-1];}sort($a);var_dump(($a[$c/2]+$a[$c/2+~$c%2])/2,$f,$a,$a[0],max($a),sqrt($d/$c));}

Try it online.

05AB1E, 27 (or 25?) bytes
If the order is mandatory:
O,P,ÅA,Åm,¥,{R,ß,à,ÅA-nÅAt,

Try it online.
If the order doesn't matter:
O,P,Åm,¥,{R,ß,à,ÅA=-nÅAt,

Does the average just before the standard deviation, every other operation is in the same order.
Try it online.
Explanation:
O         # Sum the (implicit) input-list
 ,        # Pop and print it with trailing newline
P,        # Same for the product
ÅA,       # Same for the average
Åm,       # Same for the median
¥,        # Same for the deltas / forward differences
{R,       # Same for the descending sort (sort + reverse)
ß,        # Same for the minimum
à,        # Same for the maximum
          # Same for the standard deviation:
ÅA        #  Get the average of the (implicit) input-list
  -       #  Subtract it from each value in the (implicit) input-list
   n      #  Square each
    ÅA    #  Take the average of this list
      t   #  Take the square-root of that
       ,  #  And print it as well

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


text:
Universal (rule-bending) Code Golf solver
Code golf always involves some answers that bend the rules more or less by breaking constraints that the challengers took for granted or just haven't thought about and didn't list in the rules. One of these interesting loopholes is the possibility to output more than the challenge asks for to get a better result.
Taking this to extremes, we can write an universal code golf solver that prints the desired output — if you don't care that it might take ages and outputs lots of other stuff before and after it.
All we need to output is a sequence that is guaranteed to contain every possible subsequence. For this code golf, this will be the Ehrenfeucht-Mycielski sequence:

The sequence starts with the three bits 010; each successive digit is
  formed by finding the longest suffix of the sequence that also appears
  earlier within the sequence, and complementing the bit following the
  most recent earlier appearance of that suffix.
Every finite subsequence of bits occurs contiguously, infinitely often
  within the sequence
The first few digits of the sequence are:

010011010111000100001111... (sequence A038219 in OEIS).

Combining 8 bits of the sequence to a byte, we'll get ASCII output that we can output to the screen or to a file and that contains every possible finite output. The program will output parts of pi, the lyrics of “Never gonna give you up”, some nice ASCII art, its own source code, and everything else you could want it to output.
For testing correctness, here are hashes for the first 256 bytes of the sequence:
MD5: 5dc589a06e5ca0cd9280a364a456d7a4
SHA-1: 657722ceef206ad22881ceba370d32c0960e267f

The first 8 bytes of the sequence in hexadecimal notation are:
4D 71 0F 65 27 46 0B 7C

Rules:

Your program must output the Ehrenfeucht-Mycielski sequence (nothing else), combining 8 bits to a byte/ASCII character.
Shortest program (character count) wins. Subtract 512 from your character count if you manage to generate the sequence in linear time per generated byte.

The longest suffix in 010 which appeared earlier in that sequence is 0, isn't it? And the most recent earlier appearance is just the second 0. And until now, nothing follows the second 0, so there is nothing we can build a complement on. I'm not a native english speaker - maybe I just got it wrong. The wikipedia article uses the same words, but has a longer sequence so I would name it "the most recent ... which has a follower".

Pedantic quibble: pi will never appear - only every finite string will be contained in the output.

I have another question: May a repetition overlap? For example in 111, (1[1)1]?

@KeithRandall: I would prefer a sequence which is guaranteed not to contain 'Never gonna give you up' and productions of similar kind.

@userunknown I think they're just relying on the idea that the most recent suffix is not "earlier" in the string, being at the end, so it is automatically not considered.

@breadbox: Maybe you can clarify, why the first triple-one: 111 is followed by a zero? Since it is the first 111, we have to search for a shorter sequence - maybe 11? There is the overlapping 11 which is followed by a 1, so the next character has to be a 0. The 11 to the left is followed by 0 so this would lead to another 1. So we have to accept overlaps?

@userunknown Or look at it this way: if you don't defined "earlier" to exclude the end of the string, then it the longest match will necessarily always be at the end. Which is obviously uninteresting, and therefore excluded. Think like a mathematician instead of a programmer and it makes perfect sense!

@KeithRandall: Of course. Corrected now.

@userunknown: It says "complementing the bit following the most recent earlier appearance of that suffix". "Most recent" will lead you to the 11 "most right", but "earlier appearance" excludes overlappings with the suffix (010011010111), so the 11 you choose is the other one: 010011010111

@schnaader: But then a 0 follows, you have to complement it, which leads to 1, and you would end with a series of 4 times 1 - but there is only 111.

@userunknown: Sorry, messed it up. Earlier appearance includes overlappings. Every position is fine as long as it's not the suffix itself which isn't followed by a bit. We choose the rightmost match position. So it is the other way round, we are choosing 010011010111 indeed, so a 0 is added.

@schnaader: But you have to test out the example that far too, to find that out; don't you? It's not clear from the description of the rules; nor at wikipedia, and more so not here.

It might be worth mentioning that the mere presence of an "answer" embedded at an unspecified location in an infinite string cannot be regarded as "outputting" that answer, of course. Also, this particular sequence is just one example of a disjunctive sequence -- there are infinitely many sequences like this.

C, –110 chars
This version of the program uses the linear-runtime algorithm to generate the sequence. Subtracting 512 from the 402 chars in the program gives a total of negative 110.
#define C v=calloc(7,8),v->p=p
#define G(F,K)u->F[d[K]]
#define S(F,T)G(f,T)=F,G(t,T)=T,G(n,T)=
struct{int p,f[2],t[2];void*n[2];}r,*u,*v,*w;char*d,c;p,b,h,i,j,k;
main(s){for(;d=++p-s?d:realloc(d,s*=2);){d[i=p]=b;c+=c+b;p%8||putchar(c);
for(u=&r;b=u->p,u->p=p,w=G(n,k=i);S(i,k)v=G(n,k),u=v)for(h=G(f,k),j=G(t,k);j>h;--i,--j)
if(d[i]-d[j]){S(i,k)C;u=v;S(h,j)w;S(0,i)C;b=w->p;goto x;}S(0,i)C;x:b=1-d[b+1];}}

As per the problem, the program runs in an infinite loop, which necessitates lots of memory allocation, and using realloc() to keep the sequence contiguous can contribute to heap fragmentation. You can improve the program's memory usage by replacing calloc(7,8) on the first line with calloc(1,sizeof*v). This will help especially on a 32-bit machine, where 56 is likely too large by a factor of two.
The code is kind of unreadable, and not in an interesting way; for that I apologize. Frankly, even the ungolfed version isn't terribly clear:
#include <stdio.h>
#include <stdlib.h>

typedef struct branch branch;
typedef struct node node;

struct branch {
    int from, to;
    node *next;
};

struct node {
    int pos;
    branch br[2];
};

static node root = { 0 };

static unsigned char *data = NULL;
static int endpos = 0;
static int size = 1;

static node *mknode(void)
{
    node *n;

    n = calloc(1, sizeof *n);
    n->pos = endpos;
    return n;
}

static branch *getbranch(node *n, int p)
{
    return &n->br[data[p]];
}

static void setbranch(node *n, int from, int to, node *next)
{
    n->br[data[to]].next = next;
    n->br[data[to]].from = from;
    n->br[data[to]].to = to;
}

int main(void)
{
    node *u, *v, *w;
    int follower, from, i, i0, j;
    int out, b;

    out = b = 0;
    for (;;) {
        ++endpos;
        if (endpos == size) {
            size *= 2;
            data = realloc(data, size);
        }
        data[endpos] = b;
        out = (out << 1) | b;
        if (endpos % 8 == 0) {
            putchar(out);
            out = 0;
        }

        i = endpos;
        u = &root;
        for (;;) {
            follower = u->pos + 1;
            u->pos = endpos;
            w = getbranch(u, i)->next;
            if (!w)
                break;
            i0 = i;
            from = getbranch(u, i0)->from;
            for (j = getbranch(u, i0)->to ; j > from ; --j) {
                if (data[i] != data[j]) {
                    /* divide branch */
                    v = mknode();
                    setbranch(u, i, i0, v);
                    u = v;
                    setbranch(u, from, j, w);
                    setbranch(u, 0, i, mknode());
                    follower = w->pos + 1;
                    goto bitfound;
                }
                --i;
            }
            v = getbranch(u, i0)->next;
            setbranch(u, i, i0, v);
            u = v;
        }
        /* extend branch */
        setbranch(u, 0, i, mknode());

      bitfound:
        b = 1 - data[follower];
    }
}

(The ungolfed code above is based on the code written by Grzegorz Herman and Michael Soltys, as referenced in the problem description, and from Soltys' home page.)
Thanks to @schnaader and @r.e.s. for reporting a bug in the initial version.

Nice! That's what I hoped for with the -512 bonus.

Any idea why this causes crashes on by system? All of the golfed, ungolfed and malloc modified versions stop output after about 10000 bytes and keep on allocating memory, prog > out.dat gives an instant crash with only ~700 KB memory usage. If I insert printf("\n%i\n", size); after realloc, the biggest output is 4. System: Windows 7 Prof. 64-Bit, 4 GB RAM, GCC 4.6.1

(+1) I find that with Ubuntu12.04/gcc, both of your programs compile and produce the correct output ... With Win7/mingw/gcc, both programs compile but produce segmentation faults ... With Win7/lcc, the ungolfed version works, but the golfed version produces segmentation faults.

That sounds like use of uninitialized data to me. Sure enough -- I don't have access to a Windows machine, but valgrind shows the problem. Looks like I reproduced this bug from the original reference implementation, too. Fortunately it's an easy fix; thanks for reporting it!

Great, works like a charm now.

Ruby, 109 104 101 94 characters
s=?0
loop{s=(s[/(.*).*\1/][/.#{$1}/]<?1??1:?0)+s
s.size&7<1&&$><<[s.reverse.to_i(2)].pack(?C)}

Implementation in Ruby using regular expressions for suffix search. Since it takes quite a long time until out-of-memory the program has to be terminated by the user.
Edit: I just noticed that it is enough to start with the sequence 0.
Edit 2: The proposal of r.e.s. saves 2 characters, some others because we do not have to cut out a single byte before pack.

Using s=(s[/(.*).*\1/][/.#{$1}/]<?1??1:?0)+s will save another two characters.

@r.e.s. This works indeed. Thank you.

Can you get rid of the parentheses around ?C?

Perl, 95 chars
I actually had a halfway decent version of this at first. Then as I golfed, each version got slower. Increasingly slower.
$|=$_="010";
y///c%8||print pack"B*",/(.{8})$/while/(.+)$(?(?{m|.*$^N(.)|})(?{$_.=1-$^N})|(?!))/

The first three characters ($|=) aren't necessary, strictly speaking ... but without that there, you'd typically have to wait for the script to finish generating a full 4096 bytes before you'd see any of the output. And that would take hours. Maybe centuries; I'm not sure. Did I mention that this program's performance kind of deteriorates over time? So because of that I kind of felt compelled to include them in the count.
On the other hand, this script has one of the ugliest regexes I've ever created, so I think I'm proud of it.

Don't worry about the performance, the algorithm is O(N^3) without optimizations. My simple Delphi program I wrote took about 30 seconds for 256 bytes,but about an hour for 1024 bytes, so I'd assume 4096 bytes to take one or several days. Of course, RegEx and space optimizations have the potential to make it worse :)

My initial Perl script took 10 seconds for 256 bytes. This version takes 90 seconds. (Nor does it appear to be a linear slowdown.)