text:
Random Pixel Poking
Your task is simple: write a program that will replace random pixels in a black 16px * 8px rectangle (width by height) with a white pixel.
The holes must be uniformly random, and you should output the 16px by 8 px image with the white pixels inserted.
Replace only 1 pixel per column (16 total replaced pixels)
You don't take any input, and you can't rely on the image being stored elsewhere on the computer.
This is code-golf so the program with the shortest bytecount wins!

Should the output change when executing the program multiple times?

@Quentin yes it should

Related: Display random colored pixels

MATL, 15 14 13 bytes
8tE2$r&S1=3YG

Example (with MATL compiler running on MATLAB):

Or try it at MATL Online! (If it doesn't run the first time, press "Run" again or refresh the page). Note that the image is scaled by the online interpreter for better visualization.
This is a port of my Octave / MATLAB answer (see explanation there). Here are the equivalent statements:
MATL        Octave / MATLAB
----        ---------------
8tE         8,16
2$r         rand(...)
&S          [~,out]=sort(...)
1=          ...==1
3YG         imshow(...)

Pyth - 16 15 bytes
Outputs image to o.png.
.wCm.S+255mZ7y8

Example image:

C, 85 100 bytes
main(c){char a[138]="P5 16 8 1 ";for(srand(time(0)),c=17;--c;a[9+c+(rand()&112)]=1);write(1,a,138);}

Writes a PGM image file to stdout (call it with prog >out.pgm).
Ungolfed and explained:
main(c) {
    // A buffer large enough to contain the whole image,
    // pre-filled with the PGM header.
    // This is a binary greyscale (P5) image with only two levels (1),
    // Because a binary bitmap would require pixel packing.
    char a[138] = "P5 16 8 1 ";

    // c iterates from 16 to 1 over the columns
    for(
        srand(time(0)), c = 17;
        --c;

        // (rand() % 8) * 16 is equivalent to (rand() & 7) << 4
        // Since all bits are equally random, this is equivalent
        // to rand() & (7 << 4), that is rand() & 112.
        // This picks a pixel from the first column, which is then
        // offset to the correct column by c - 1 + 10
        // (10 is the length of the header).
        a[9 + c + (rand() & 112)] = 1
    )
        ; // Empty for body

    // Write the whole buffer to stdout
    write(1,a,138);
}

Updates:

OP has clarified that the output should change with each execution, lost 15 bytes to srand(time(0)) (:()

Processing, 74 73 bytes
fill(0);rect(0,0,15,7);stroke(-1);for(int i=0;i<16;)point(i++,random(8));

Sample output:

Explanation
fill(0);               //sets the fill colour to black
rect(0,0,15,7);        //draws a 16*8 black rectangle
stroke(-1);            //set stroke colour to white
for(int i=0;i<16;)     // for-loop with 16 iterations
 point(i++,random(8)); //  draw a point at x-coordinate i and a random y coordinate
                       //  the colour of the point is white since that is the stroke colour

Ruby, 61 bytes
puts'P116 8';puts Array.new(16){[*[1]*7,0].shuffle}.transpose

This is a full program that outputs the image in netpbm format to stdout.
Sample output:

puts'P116 8';   # output the netpbm header (P1 for black and white, 16x8)
puts            # then output the data as follows:
Array.new(16){  # make a 16-element array and for each element,
[*[1]*7,0]      # generate the array [1,1,1,1,1,1,1,0] (1=black 0=white)
.shuffle}       # shuffle the array
.transpose      # transpose the rows/columns of the 2d array (so that each column
                # has one white pixel)

Octave / MATLAB, 48 37 35 bytes
[~,z]=sort(rand(8,16));imshow(z==1)

Example (on Octave):

Explanation
           rand(8,16)                  % 8×16 matrix of random values with uniform
                                       % distribution in (0,1)
[~,z]=sort(          );                % Sort each column, and for each output the
                                       % indices of the sorting. This gives an 8×16
                                       % matrix where each column contains a random
                                       % permutation of the values 1,2,...,8
                              z==1     % Test equality with 1. This makes all values
                                       % except 1 equal to 0
                       imshow(    )    % Show image, with grey colormap

HTML+JavaScript, 148 bytes

c=O.getContext`2d`;for(x=16;x--;){r=Math.random()*8|0;for(y=8;y--;)c.fillStyle=y-r?'#000':'#fff',c.fillRect(x,y,1,1)}
<canvas id=O width=16 height=8>

Befunge, 90 bytes
This generates a PBM file written to stdout.
>030#v_\2*>>?1v
:v9\$<^!:-1\<+<
|>p1+:78+`!
>"P",1..8.28*8*v
.1-\88+%9p:!#@_>1-::88+%9g:!!

Try it online!
Explanation
The top three lines make up the random number generator, storing 16 random 3-bit numbers (i.e. in the range 0-7) on the tenth line of the playfield. Line four writes out the PBM header, and the last line then generates the pixels of the image. This is done by counting down the 16 random numbers as the pixels are output - when the number corresponding to a particular column reaches zero we output a 1 rather than a 0.
Sample output (zoomed):

Your online version says (in debug): "Unsupported instruction '' (0x05) (maybe not Befunge-93?)". And output is string-numerical rather than an image.

Mathematica, 77 60 bytes
Image[{RandomInteger@7+1,#}->1&~Array~16~SparseArray~{8,16}]

Sample Output

Explanation
{RandomInteger@7+1,#}->1&~Array~16

Make replacement rules for each column; replace a randomly selected position with 1.
... ~SparseArray~{8,16}

Create a SparseArray with size 8x16 from the replacement rules. The background is 0 by default. (8x16 because Mathematica counts rows first)
Image[ ... ]

Convert the SparseArray into an Image object.
77 byte version
ReplacePixelValue[Image@(a=Array)[0&~a~16&,8],{#,RandomInteger@7+1}->1&~a~16]

R, 76 bytes
a=matrix(0,8,16);for(i in 1:16)a[sample(1:8,1),i]=1;png::writePNG(a,'a.png')

Uses package png to output to a file.
Example output:

QBasic, 59 bytes
RANDOMIZE TIMER
SCREEN 9
FOR x=0TO 15
PSET(x,RND*8-.5)
NEXT

Pretty straightforward. The -.5 is needed because PSET with non-integer arguments uses round-to-nearest instead of floor or truncate (and -.5 is shorter than INT()).
The image in question is displayed at the top left corner of the output window. A (cropped) example:

Java, (Does it even matter Bytes, AKA 244 + 18 import = 262)
import java.awt.*;static void l(){new Frame(){public void paint(Graphics g){int x=50;int i=16;g.setColor(Color.BLACK);g.fillRect(x,x,16,8);g.setColor(Color.WHITE);for(;i>0;i--){int y=(int)(Math.random()*8);g.drawLine(x+i,x+y,x+i,x+y);setVisible(1>0);}}}.show();}

Was wonky because the coordinate system includes the frame window pane... So you need to buffer by at least 26 bytes or nothing shows up, hence the x=50 bit.

I know it's been a while, but you can golf it to 238 bytes: import java.awt.*;v->{new Frame(){public void paint(Graphics g){int x=50,i=16,y;g.setColor(Color.BLACK);g.fillRect(x,x,i,8);for(g.setColor(Color.WHITE);i>0;g.drawLine(x+i,x+y,x+i--,x+y),setVisible(1>0))y=(int)(Math.random()*8);}}.show();} (Changes done: static removed; Java 8 lambda; some ints removed; i=16 reused; put things inside the for-loop to remove brackets and ;)

194 bytes: import java.awt.*;v->{new Frame(){public void paint(Graphics g){int x=50,i=16,y;g.fillRect(x,x,i,8);for(g.setColor(Color.WHITE);i>0;y*=Math.random(),g.drawLine(x+i,x+y,x+i--,x+y))y=8;}}.show();}

Postscript (65 bytes)
0 0íkà0ícà8íc0 8ícííB1à1íù16{0 randàíj0.5í©ík1 0íÖíß1 0í≠}íÉ

Ungolfed version:
0 0 moveto
16 0 lineto
16 8 lineto
0 8 lineto
closepath
fill
1 1 1 setrgbcolor
16{0 rand 16 mod 0.5 sub moveto 1 0 rlineto stroke 1 0 translate}repeat

SmileBASIC, 30 bytes
FOR I=0TO 15GPSET I,RND(8)NEXT

Chip-8, 12 bytes
0xA201 'Load sprite at address 201 (which is the second byte of this instruction)
0xC007 'Set register 0 to a random number from 0 to 7 (rnd & 0x7)
0xD101 'Draw sprite. x = register 1, y = register 0, height = 1
0x7101 'Add 1 to register 1
0x3110 'If register 1 is not 16...
0x1202 'Jump to second instruction

Draws the image on the screen.

Tcl/Tk, 163
Two different approaches render to the same byte extent:
grid [canvas .c -w 16 -he 8 -bg #000 -highlightt 0]
.c cr i 8 4 -i [set p [image c photo -w 16 -h 8]]
set x 0
time {$p p #FFF -t $x [expr int(rand()*8)];incr x} 16

grid [canvas .c -w 16 -he 8 -bg #000 -highlightt 0]
.c cr i 8 4 -i [set p [image c photo -w 16 -h 8]]
time {$p p #FFF -t [expr [incr x]-1] [expr int(rand()*8)]} 16

VBA Excel, 86 105 bytes
using immediate window
Cells.RowHeight=42:[a1:p8].interior.color=0:for x=0to 15:[a1].offset(rnd*7,x).interior.color=vbwhite:next

This solution unfortunately does not make the cells of the activesheet square, as is required for Excel VBA pixel art solutions - A more valid solution would be Cells.RowHeight=42:[A1:P8].Interior.Color=0:For x=0To 15:[A1].Offset(Rnd*7,x).Interior.Color=-1:Next

ah yes I forgot. I remember I adjusted it manually.  Thanks :)

(and you can use -1 instead of vbWhite - full explanation of why here)


text:
Merry Golfmas, Everyone!
It's Christmas everybody, and here's a code-golf challenge to celebrate. You need to make a program to print out a present. Specifically, the words "Merry Christmas". BUT, there is a catch: this program must only work if it is the 25th of December. If the code is run on any other day, then the program should crash.
This is Code-Golf, so the answer with the least amount of bytes wins.
Merry Christmas!

Welcome to PPCG, please refer to the sandbox if you have an idea for challenges.

Yeah that was ermmmmm. .. yeah 25th sorry

Related challenges: Merry Christmas (and a Happy New Year), Christmas Countdown, and Is it Christmas?

Golfy Codemas! :)

You say the program must crash. Does exiting without an error count?

No, it must be a crash. You can't quit the aplication

Just to be extra clear, does an error count if it stops the application?

Yes that counts

@PhiNotPi Those challenges are different. This is not asking for a countdown and does not involve waiting to give output

I think these challenges are very different as waiting for a date is a completely different operation to checking if it is one

Are you sure this is [tag:kolmogorov-complexity]? KC questions are normally about compressing a constant output. Merry Christmas can't really be compressed, this post is more about date/time verification.

@Flp.Tkc I know. I didn't choose the tag myself

25 of December in what timezone? Local timezone? UTC?

do I leap years?

Pyke, 21 bytes
.dↄґ6C65h*325q/Al

Try it here!
     C65h*        -   multiply the day by the (current month + 1)
          325q    -  ^ == 325
    6         /   - 6 / ^
.dↄґ              -  load "merry christmas"
               Al - ^.capwords()

Or 18 bytes noncompetitive.
.dↄґ6Cs6Y1q/Al

Exactly the same except for this section:
Cs6Y1q
C      -    get_time()
 s6    -   add 1 week
   Y   -  get day of the year
    1q - ^ == 1

Try it here!

This fails if it's October 30th, does it not?

@carusocomputing 30 * (10+1) = 330 not 325

JavaScript, 55 53 46 bytes
Note: this has only been tested in Google Chrome, program may behave differently from browser to browser (or device to device)
2 bytes saved thanks to @ConorO'Brien
7 bytes saved thanks to @ETHProductions
alert(/c 25/.test(Date())?"Merry Christmas":a)

Exits with Uncaught ReferenceError: a is not defined if the date is not Dec 25. I'm not really sure if this counts as crashing

alert(/c 25/.test(Date())?"Merry Christmas":a)

How about .slice(6,10)=="c 25"?

@ConorO'Brien Thanks! That's smart :)

@ETHproductions I can't think of any day or month that ends in c (Oct comes close, but still doesn't satisfy the regex). Thanks for the tip!

The result of Date() is completely implementation dependent. For example, I expect it to vary with the language and location of the machine.

@Oriol Then I will specify the browser in my answer

PHP, 39 38 bytes, not competing (doesn´t crash)
<?=date(md)-1225?"":"Merry Christmas";

or
<?date(md)-1225?die:0?>Merry Christmas

or
<?=["Merry Christmas"][date(md)-1225];

Can anyone golf 4 bytes off date(Lz)%1001-358? :D

Does this crash?

You can leave out "" in the first code which saves you 2 Byte. If it wasn't for damn leap years, you could save 2 Byte more by replacing md by z and 1225 by the number of the day of the year of December 25th.

An alternative: eval((date(md)^TQZZ).'"Merry Christmas";'); (43 bytes)

@UTF-8: If I remove the "", the ternary result will be 1, not empty. And right, the damn leap years. This would be shorter for New Years Day.

@Titus I'm pretty sure I checked. I might be wrong, though, and now checked, again. It prints -1121, not 1, which is great because now we have 3 different results.

@edc65: Uhm no. Sorry, didn´t catch that part. Ismael´s alternative does.

@UTF-8: Your´re right. I mostly use the Elvis for boolean values; and that would print 1. This would print the result of the calculation. and 0104-1225 is 1121.

@Titus I can't believe I didn't know that operator exists and just learned something new. Thanks. :)

Python 3, 66 63 bytes
Thanks to ideas from JavaScript / ES answers here I managed to squeeze some bytes. Index a dictionary - non-existent keys will raise a KeyError. The following code works in local time zone
import time;print({1:'Merry Christmas'}['c 25'in time.ctime()])

The output format for ctime isn't locale-dependent - the format is always ~ 'Sun Dec 25 19:23:05 2016'. Since only in December does the 3-letter abbreviation end with c, it is safe to use 'c 25'in time.ctime() here.

Previous version:
This works in UTC time zone. For local time zone one needs to s/gm/local for 3 more bytes. For Python 2, one can remove parentheses from print for 65 bytes.
import time;print({(12,25):'Merry Christmas'}[time.gmtime()[1:3]])

The construct throws KeyError on other dates:
>>> import time;print({(1,1):'Happy New Year'}[time.gmtime()[1:3]])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
KeyError: (12, 25)

Does this crash on other days (it's supposed to)?

I can't get this one to run as it objects to the tuple as a key Try it online!. If you change it to import time;print{'2512':'Merry Christmas'}[time.strftime("%d%m")] and label it Python 2 it's still 66 bytes and crashes with a KeyError on dates other than 25 Dec.

@ElPedro oops :D should have been 1:3, I copied my test code by accident

Picked up on that when I borrowed your gmtime() idea for my answer. Hope you don't mind :-)

R, 52 61 58 bytes
`if`(format(Sys.Date(),"%m%d")=="1225","Merry Christmas",)

If the current date is not the 25th of December then an error is returned because no third argument is supplied to if.
Edit: Fixed a silly error

Sorry about my little typo. I meant to say 25tg

This only works this year though!

@Erresen Ah right, silly mistake. Fixed now though.

Python 2, 68 67 65 bytes
-1 with thanks to @muddyfish
Thanks to @AnttiHaapala for the idea that saved another couple.
import time;print['Merry Christmas'][(12,25)!=time.gmtime()[1:3]]

Try it online!
Throws an IndexError if not 25th Dec.
Non-competing version for 59 bytes as it only works for non Leap years (uses day of year which is 360 this year but 361 in leap years)
import time;print['Merry Christmas'][360!=time.gmtime()[7]]

Can't you save a byte by using a list instead of a tuple?

@muddyfish Thanks, good catch.

Nice one, my idea was 2 extra bytes :P

Thanks. That was also my 67 byte version until I commented on the answer from @AnttiHaapala and thought about gmtime() to shave a couple off. I have to admit, I wish there was more I could do with the day-of-year idea though.

You can save 1 byte with: time.ctime()[6:10]!='c 25'

My first time around here... Started with the best language ever for this job:
Java, 200 188 bytes (thanks to @Daniel Gray), 186 bytes removing "ln" from print.
import java.util.*;public class a{public static void main(String[]r){Calendar c=Calendar.getInstance();if(!(c.get(2)==11&&c.get(5)==25)){int i=1/0;}System.out.print("Merry Christmas");}}

Try it here!

Welcome to PPCG! Nice first post, even though java isn't quite the shortest.

You can change the Calendar for * and save a few bytes. You could also shorten the name of the args parameter in the main method, I think...

@Daniel Gray, You are absolutely right, thanks!

Welcome! You can save 10 bytes if you replace "public class" with "interface" and remove the public modifier from main, making it "interface a{static void main..." This, however, will prevent Compilejava from being able to run it online.

MATL, 34 33 bytes
'Merry Christmas'IHh&Z'5U12h=?}Yl

This works in current version (19.7.0) of the language. To cause the error, the following code exploits the fact that the logarithm of a string gives an error (this may change in future versions).
Try it online!
Explanation
'Merry Christmas'  % Push this string
IHh                % Push 3, then 2, concatenate: gives array [3 2]
&Z'                % Get 3rd and 2nd outputs of clock vector: current day and month
5U12h              % Push 5, square, push 12, concatenate: gives [25 12]
=                  % Compare if corresponding entries are equal in the two arrays
?                  % If all entries are equal: do nothing
}                  % Else
  Yl               %   Logarithm. Gives an error when applied on a string
                   % End (implicit). Display (implicit)

C# / CS Script 106 100 99 bytes
99 byte solution
using System;int i;Console.WriteLine(DateTime.Now.ToString("dM")=="2512"?"Merry Christmas":i/0+"");

Try it here!
100 byte solution (prefer this one... a bit different)
using System;int i;Console.WriteLine(DateTime.Now.AddDays(7).DayOfYear==1?"Merry Christmas":i/0+"");

Explained:
using System;
int i;

// if today plus 7 days is the first day of the year, then it's xmas!
Console.WriteLine(DateTime.Now.AddDays(7).DayOfYear==1
    ? "Merry Christmas"

// otherwise divide i by 0
    : i/0+"");

DateTime.Now.AddDays(7).DayOfYear==1 is one byte shorter than DateTime.Now.ToString("ddMM")=="2512" but 1 byte longer than DateTime.Now.ToString("dM")=="2512"

You can use $"{DateTime.Now:dM}"=="2512". dM is ambiguous, but not for "2512".

@Kobi I can't use string interpolation for CS Script :(

You can if you use LinqPad (e.g. $"{DateTime.Now:dM}"=="2512"?"Merry Christmas":1/1-1+"" 55 bytes)  =)

Why int i and notjust 1/0?

@SeeOneRhino the compiler recognises that as an error and won't compile

@KennethK. I'll have to try linqpad if it can save me a few bytes!

@KennethK. Tried Linqpad, but your 55 byte solution doesn't work. 1/1-1 is zero not an error, as the division is done before subtraction, and 1/(1-1) doesn't compile. It's a nice tool though - thanks for the pointer.

@Erresen Ah, my mistake. I didn't test thoroughly enough. Tweaked:  $"{DateTime.Now:dM}"=="2512"?"Merry Christmas":"".Remove(1) (59 bytes)

QBIC, 48 bytes
~left$$|(_D,5)=@12-25||?@Merry Christmas|\?a(12)

Explanation:
~             IF
left$$|(_D,5) the date string starts with
=@12-25|      the string "12-25"
|             THEN
?@Me..as|     PRINT "Merry Christmas"
\             ELSE
?a(12)        Print the twelfth index of an undefined array.
              Since there are only 11 elements in undefined arrays, this
              results in an index-out-of-bounds error.
The the IF statement is auto-closed by QBIC.

This assumes American MM-DD date notation. This would be shorter if I'd finally make a Substring function in QBIC.

What happens on days that aren't Christmas? Does it crash as it's supposed to?

@Erresen it does now.

05AB1E, 32 21 bytes
Saved 11 bytes thanks to Adnan's string compression :) .
1žfže‚12D·>‚Q÷”ÞÙŒÎ”×

Explanation
 žfže‚                Push [current month, current day]
      12D·>‚          Push [12, 25]
            Q         Push tmp = 1 if the two arrays are equal, tmp = 0 otherwise
1            ÷        Evaluate x = 1/tmp. If tmp = 0 a division by 0 exception is thrown
              ”ÞÙŒÎ”× Implicitly display "Merry Christmas" x times

Try it online!
I did what came to mind first, so there may be better approaches for this one. But PPCG deserves a Merry Christmas in 05AB1E as well ;) .

Also, x is short for duplicate and double :).

bash + Unix utilities, 51 49 47 bytes
((`date +%m%d`-1225))&&${};echo Merry Christmas

*Thanks to @KenY-N for pointing out that the quotes in the echo can be removed, and to @IporSircer for reducing the condition size by 2 bytes.

That gives me bash: ${}: bad substitution error. Also you can drop the quotes from Merry Christmas to save two bytes. Furthermore, [ \date +%m%d` = 1225 ]&&echo Merry Christmas` works for me, equalling my 45 bytes.

@KenY-N  The error is intentional: the program is supposed to crash on days other than Christmas.  Thank you for mentioning that the quotes in the echo can be dropped; I missed that.

Oops, missed that requirement! Tested out by changing the date string, and I see now that it doesn't crash. Deleted my answer... But, I have an alternative, so let me update it.

Try replacing ${} with !- to beat me by one byte. I'll upvote you as you win.

And now I've saved one more byte, so it's a tie again.

@KenY-N Thanks, but I'm not going to change ${} to !- since I think the latter will only work correctly on the command line, not in a script (unless you turn history substitution on, which would take additional characters).

You can still save 2 byte at the beginning and win: ((\date +%m%d`-1225))&&`

Thanks, @IporSircer, I've made the change.  It actually does need && with this variant.  (The condition is true if its numerical value is non-zero, which happens when it's not Christmas.)

C#/CS Script, 96 Bytes, Mostly Plagiarized from Erresen
using System;Console.WriteLine(DateTime.Now.AddDays(7).DayOfYear==1?"Merry Christmas":1/0+"");

Deletes the int i declaration in favor of hard coding the division. I would leave this as a comment but don't have the reputation.

Welcome to PPCG! Nice first post! Don't worry about the comment/answer thing, it doesn't matter too much.

Groovy, 57 bytes
print new Date().format("Md")=="1225"?"Merry Christmas":b

Crashes on dates other than 25.12. with groovy.lang.MissingPropertyException because b is not defined.

Python 2, 69 77  75 or 72 70 Bytes
import time
if time.strftime("%d%m")=="2512":print"Merry Christmas"
else:1/0

If it doesn't matter if it exits with an error when it is Christmas, then:
import time
if time.strftime("%d%m")=="2512":print"Merry Christmas"
1/0

EDIT:
Thanks @Flp.Tkc for pointing out that I needed to raise an error
-2 Bytes from @Max for pointing out about removing colons from the strftime function

It's meant to crash if it's not Christmas, this just exits normally.

You can save 2 bytes removing the colons --> '%d%m' == '2512'

@Max OK, thanks for the tip. I hadn't used this function before, so I hadn't thought of doing that

save another 3 bytes with: time.ctime()[6:10]=='c 25'

Stacked, 42 bytes
Try it here!
('Merry Christmas')'MMDD'date'1225'=¬#out

This creates a single-element array containing namely 'Merry Christmas!'. After, it puts the date into a string with the month followed by the day. It checks for equality with '1225' (Christmas), inverts it with ¬, then gets that member from the preceding array. If it isn't Christmas, this will error with an index error. Otherwise, it prints Merry Christmas. (Change the date in the string to see how it works on other days.)

Batch, 66 bytes
@echo off
if %date:~0,5%==25/12 echo Merry Christmas&exit/b
if

The trailing newline is significant, as it causes parsing of the if statement to fail. You may need to tweak the date check to match your local date format.

CJam, 28
et[C25]#1="Merry Christmas"/

Try it online
Explanation:
et                   push an array of current [year month day hour ...]
[C25]                push the array [12 25] (C=12)
#                    find the position of the 2nd array within the first one
1=                   compare it with 1, resulting in 1 for 1 and 0 otherwise
"Merry Christmas"/   split "Merry Christmas" into pieces of that length
                      (it crashes if the length is 0)
                     at the end, all the pieces are concatenated
                      and printed automatically

C#, 122 104 bytes
18 bytes saved, thanks to @raznagul
using System;i=>{if(DateTime.Now.AddDays(7).DayOfYear==1)Console.Write("Merry Christmas");else{i/=0;};};

It adds 7 days to the current day, and checks if it is the first day of the year, if yes, it displays "Merry Christmas", otherwise it divides by zero.

The return is not necessary. Use i instead of ().

Mathematica, 46 bytes
If[Today[[1,2;;]]=={12,25},"Merry Christmas!"]

Now saves 2 Bytes over Today

Also, you need a crash in the False outcome, so I think something like Quit[] or 1/0 should suffice.

Common Lisp, 140
(let((m(multiple-value-list(decode-universal-time(get-universal-time)))))(if(and(eq(nth 3 m)25)(eq(nth 4 m)12))(write"Merry Christmas")(c)))

Crashes with undefined function if the date isn't right.

awk, 29 bytes (+ length("Merry xmas"))
v=1225==strftime("%m%d")||1/0

Running it:
$ echo Merry xmas | awk 'v=1225==strftime("%m%d")||1/0'
awk: cmd. line:1: (FILENAME=- FNR=1) fatal: division by zero attempted

Season greeting is piped to awk. strftime returns month+day (for example 1226) and if it matches 1225 $0 record gets outputed. Result of comparison 1225==1226 is placed to v var which is used to divide 1 if the date comparison fails.

C#.NET, 180 172 171 bytes
Saved 8 bytes thanks to Kritixi Lithos
Saved 1 byte thanks to Kritixi Lithos, again ;)
namespace System{class P{static void Main(string[] args){var d=DateTime.Today;if(d.Day==25)if(d.Month>11){Console.Write("Merry Christmas!");return;}throw new Exception();}}}

Alternative, ungolfed variant:
namespace System //In System, so we don't have to use system.
{
    class Program
    {
        static void Main(string[] args) //Main function.
        {
            var d = DateTime.Today; //Get Today.
            if (d.Day == 25) if (d.Month == 12) //Day has to be 25th, Month has to be 12nd.
                {
                    Console.Write("Merry Christmas!"); return; //Prints.
                }
            throw new NotChristmasException(); //Errors/Crashes the program.
        }
    }
    class NotChristmasException : Exception { } //Holiday exception, hooray!
}

Can't you give the program a shorter class name?

You could remove some bytes by changing the "NotChristmasException" to something shorter.

@FishProHD The NotChristmasException is only in the ungolfed variant.

@KritixiLithos Thanks, changed that.

Oh, so it is. Sorry!

Can you throw new Error() in c#?

You can also change the string[] args to string[]a to save a few bytes, I think (I don't know C#, only Java and I think the same tip can apply for both)

You might be able to do if(d.Month>11) instead to save more bytes (since there are no months past #12)

@KritixiLithos Thanks alot again!

You can also change the string[] args to string[]a to save a few bytes :)

if(d.Day==25&&d.Month>11)Console.Write(...);else throw new Exception() note combined if statements and removal of braces around the Console.Write and replace   return with else. Also change var d=DateTime.Now you can get rid of exception throw with perhaps args[-1]; after renaming args to a so a[-1]; (this so not identical to divide by zeros used elsewhere)

Haskell, 116
Crashes with "Non-exhaustive patterns in function f" if it's not Christmas.
import Data.Time
f(_,12,25)="Merry Christmas"
main=getZonedTime>>=print.f.toGregorian.localDay.zonedTimeToLocalTime

Unfortunately, there's no function that allows you to just immediately get the time in a useful format, so most of this is converting the date formats.

bash command line, 45 48 49 48 bytes
date +%m%d|grep -q 1225&&echo Merry Christmas||!-
date +%m%d|grep -q 1225||!-;echo Merry Christmas

Similar to Mitchell Spector's, but use grep in silent mode to check for a match, then && will ensure that it only prints on success, and the || causes it to look up history with !-, which gives me this:
-bash: !-: event not found

And it stops execution as !- ; echo foo demonstrates. The bash documentation says that !-n refers to the current command minus n, so perhaps it is being interpreted as !-0, which gives an identical (and non-localised) error message.

Good idea, but this doesn't crash on days other than Christmas, like it's supposed to, does it?

It now gives an error on failure.

This prints an error message but it continues; it doesn't actually crash. If you replace the . with ${} then it will actually crash rather simply printing an error message and going on. I think crashing requires that the program be terminated at that point. You can tell that yours doesn't terminate by putting an extra ";echo x" at the end and seeing that it gets executed. (That's why I used ${} instead of . in my answer.) I don't know if there's some 1- or 2-character sequence you can use that will cause an actual crash.

@MitchellSpector: I found a 2 character sequence!

And now back to 48 by switching the logic so I can use ; instead of ||.

!- doesn't work in a program, does it? I think this will only do what you want if you type it from the command line, rather than in a program. (There's probably some setting you can use to turn history on inside a shell script, but that would take additional characters.)

I've been doing all my testing at the command line, not as a script; I'll highlight that in my title.

Bash is tricky that way -- there are various things that work differently (by default) in a script vs. from the command line.

Ruby, 69 bytes
if Time.now.strftime("%j")=="360";puts "Merry Christmas";else 0/0;end

Works in 2016. Doesn't differentiate between normal and leap years, may need to be adjusted for non-leap years.

ForceLang, 180 bytes
set s datetime.toDateString datetime.now()
set t "Dec 25"
def c s.charAt i
def d t.charAt i
set i -1
label 1
set i 1+i
if i=6
 io.write "Merry Christmas!"
 exit()
if c=d
goto 1
z.z

(Remember that datetime.toDateString is locale-dependent, so this may not work depending on your locale)

C#, 90 bytes
using System;Console.Write(new[]{"Merry Christmas"}[DateTime.Now.AddDays(7).DayOfYear-1]);

Throws IndexOutOfRangeException if it's not christmas.
Try it here!

source: Stack Exchange

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

sort: votes


text:
Holiday Headache
Warning: DO NOT take medical advice from this post. If you want medical advice, go to a qualified professional.
I have a headache. I need headache pills.
I'll tell you the last few doses I've had, and you tell me when I can have my next dose, without overdosing.
I'll give you this string:
P: 00:00, I: 02:00, P: 04:00, I: 06:00
And you'll give me this:
Next P: 08:00, I: 10:00
Input:
String representing the times each medication has been taken, in the following format:
P: 00:00, I: 02:00, P: 04:00, I: 06:00

This means Paracetamol was taken at 00:00 and 04:00, and Ibuprofen was taken at 02:00 and 06:00
Output (updated):
String with the time the next does of each medication can be taken, in the following format:
Next P: 08:00, I: 10:00

The output order should be in the order which the medication is to be taken.  - If Ibuprofen is to be taken at 09:35 and Paracetamol and 10:22, then the output should be Next I: 09:35, P: 10:22
If the times for the next dose of each medication are the same, the output order doesn't matter: Next P: 08:00, I: 08:00 OR Next I: 08:00, P: 08:00
If only one medication is being taken (in the input string), then only that medication should be in the output string: Next P: 02:00

Rules:

There will only ever be two types of medication, Paracetamol 'P' and Ibuprofen 'I'.
Paracetamol can be taken once every 4 hours, a maximum of 4 times within a 24-hour period.
Ibuprofen can also be taken once every 4 hours, a maximum of 4 times within a 24-hour period.
Paracetamol and Ibuprofen can be taken together, or at separate times. One doesn't count towards the dosage of the other.
The times in the input string will always be consecutive, but may roll over midnight (23:00 -> 03:00)
The times in the input string will not span more than 24 hours
Maximum of 4 times for each medication (8 max in total)
Input will always be non-empty and contain at least one medication and one time

Examples:
Two doses of each at two hour intervals:
"P: 00:00, I: 02:00, P: 04:00, I: 06:00" -> "Next P: 08:00, I: 10:00"
Single dose of Paracetamol
"P: 22:00" -> "Next P: 02:00"
Maximum Paracetamol dose within 24 hours, single Ibuprofen dose
"P: 04:05, P: 08:10, P: 12:15, I: 12:30, P: 16:25" -> "Next I: 16:30, P: 04:05"
Test cases:
"I: 06:00" -> "Next I: 10:00"
"P: 22:00" -> "Next P: 02:00"
"P: 22:00, P: 02:00, I: 06:00" -> "Next P: 06:00, I: 10:00"
"P: 00:00, I: 02:00, P: 04:00, I: 06:00" -> "Next P: 08:00, I: 10:00"
"P: 04:05, P: 08:10, P: 12:15, I: 12:30, P: 16:25" -> "Next I: 16:30, P: 04:05"
"I: 06:32, P: 08:15, I: 10:44, P: 13:03" -> "Next I: 14:44, P: 17:03"
"P: 07:30, I: 07:30, P: 11:30, I: 11:30, P: 15:30, I: 15:30, I: 19:30" -> "Next P: 19:30, I: 07:30"
"I: 07:30, P: 11:30, I: 11:30, P: 15:30, I: 15:30, P: 19:30, I: 19:30" -> "Next P: 23:30, I: 07:30"
"P: 07:30, I: 07:30, P: 11:30, I: 11:30, P: 15:30, I: 15:30, P: 19:30, I: 19:30" -> "Next P: 07:30, I: 07:30" OR "Next I: 07:30, P: 07:30"

This is code golf, so the shortest answer int bytes wins.
UPDATE:
The output can now be abbreviations of Paracetamol and Ibuprofen; P and I

I'd be nice to have some leverage on the input and output format - meta post

@GurupadMamadapur output maybe, but extracting the times and medication type from the input is half the challenge

I'd recommend you allow people to abbreviate paracetamol and ibuprofen in output as they add unnecessary length to submissions

@Cyoce yeah I agree, trying a solution myself and it's actually a bit tricky - updated the rules to allow abbreviated output

@Lynn agreed & updated

JavaScript (ES6), 367 362 354 358 bytes
Golfed version:
A=i=>i>9?""+i:"0"+i,B=(s,a=":")=>s.split(a),C=(a,b,c,d)=>[...[s,t]=B((b>3?c:d)||":"),a+` ${A(s=b>3?+s:(+s+4)%24)}:`+A(t=+t)],F=s=>{a=B(s,m=", ");for(b=c=d=e=f=p=q=0;f<a.length;g=="P:"?(b++,d=d?h:p=h):(c++,e=e?h:q=h))[g,h]=B(a[f++]," ");[i,j,k]=C("P",b,p,d),[n,o,l]=C("I",c,q,e),r=B(h)[0];return"Next "+c?b?n*60+(n<r)*1440+j<i*60+(i<r)*1440+o?l+m+k:k+m+l:l:k}

Ungolfed/commented:
// Returns a zero-padded string of the argument.
A=i=>i>9?""+i:"0"+i,

// Since we do a lot of splitting, alias it. Making the
// second argument optional (and defaulting to ':') saved
// 3 bytes
B=(s,a=":")=>s.split(a),

// Constructs a string for output, along with the time
// of the next dose, in the format [hour, minute, string].
// Arguments:               type
// a -> type (P/I)          String
// b -> amount of doses     Number
//      taken
// c -> first dose taken    String
// d -> last dose taken     String
//
// The first two values are split from the string, but
// before the array is returned, they are converted to
// integers (during the string construction).
C=(a,b,c,d)=>[...[s,t]=B((b>3?c:d)||":"),a+` ${A(s=b>3?+s:(+s+4)%24)}:`+A(t=+t)],

// Main function. Returns the time(s) for the next dose.
// Argument:                type
// s -> list of times of    String
//      and types of
//      doses taken
F=s=>{
    a=B(s,m=", "); // Split the input by comma + space,
                   // and save that string, since we
                   // need it later when constructing
                   // the output string.
    // For loop has been restructured. Original:
    // for(b=c=f=0;f<a.length;g=="P:"?(b++,d=d?h:p=h):(c++,e=e?h:q=h))
    //     [g,h]=B(a[f++]," ");
    b = 0; // P-dose counter
    c = 0; // I-dose counter
    d = 0; // Last P-dose
    e = 0; // Last I-dose
    p = 0; // First P-dose
    q = 0; // First I-dose
    for (f = 0; f < a.length; f++) {
        [g, h] = B(a[f], " ");  // g contains the type,
                                // h contains the time
        if (g == "P:") {
            b++;                // increase the counter

            if (d == 0) {   // store h in p if this is
                p = h;      // the first dose of this
            }               // type
            d = h;
        } else {
            // See the above code block for comments
            c++;

            if (e == 0) {
                q = h;
            }
            e = h;
        }
    }
    // End of restructured for loop.

    // Construct the output strings, and get the times.
    // See comments at C function.
    [i, j, k] = C("P", b, p, d);
    [n, o, l] = C("I", c, q, e);

    // Get the amount of hours of the dose taken last.
    // We use this to get the correct order of the two
    // times.
    r = B(h)[0];

    // Return statement has been restructured. Original:
    // return "Next "+c?b?n*60+(n<r)*1440+j<i*60+(i<r)*1440+o?l+m+k:k+m+l:l:k
    //==================================================
    // Start creating the output string.
    output = "Next "
    // Use the following checks to figure out what needs
    // to be part of the output and in what order.
    if (c > 0) {
        if (b > 0) {
            // Compare the times of next doses
            // P_time = (i + (i < r) * 24) * 60
            // I'm using implicit conversion of
            // booleans to numbers. If the next
            // dose is past midnight, add 1 * 24
            // to the time, so it is compared
            // correctly.
            // Then add the minutes to the number.
            P_time = i*60+(i<r)*1440+o;
            I_time = n*60+(n<r)*1440+j;

            if (I_time < P_time) {
                output += l + m + k; // I first
            } else {
                output += k + m + l; // P first
            }
        } else {
            output += l; // Just I
        }
    } else {
        output += k; // Just P
    }

    // Finally, return the output
    return output;
}

To use it, call F with the string as argument like so:
F("P: 04:00, I: 06:00")

This is great, but I had a couple of problems. It seems to fail if there is only one type of pill in the input, e.g. F("P: 22:00") -> ReferenceError: q is not defined. This input will run if P&I have been referenced previously, but with old details for I.

Thanks! I just tested it and you're right about the reference error. I guess the q variable isn't reset and I didn't pay enough attention during testing. Thanks for letting me know, I'll fix it later.

Turned out to be an easy fix, but it cost me 4 bytes.

Python 3 - 437 bytes
a=input();i=p=l=-1;j=q=0
for x in a.split(", ")[::-1]:
    for y, z in [x.split(": ")]:
        s=lambda q,r,t:[t,sum([a*b for a,b in zip([60,1],map(int,q.split(':')))])][r%4<2]+[0,240][r<2]
        if y=="I":j+=1;i=s(z,j,i)
        else:q+=1;p=s(z,q,p)
        l=[l,p+i-239][j+q<2]
r=lambda d,e:("","%s: %02d:%02d, "%(d,(e/60)%24,e%60))[e>-1];p+=[1440,0][p>=l];i+=[1440,0][i>=l];print("Next "+[r("I",i)+r("P",p),r("P",p)+r("I",i)][p<i][:-2])

Explanation:
a=input();i=p=l=-1;j=q=0
for x in a.split(", ")[::-1]: #Read in reverse order, a="P: 01:00"
    for y, z in [x.split(": ")]:#Y="P", Z="00:00"
        s=
        lambda q,r,t:[t,sum([a*b for a,b in zip([60,1],map(int,q.split(':')))])]#Convert "01:01" to 61
        [r%4<2]#In case it's the first or fourth string calculate a new value, otherwise: return the original value
        +[0,240][r<2]#In case it's the last string: add 4 hours. Otherwise, leave it.
        if y=="I":j+=1;i=s(z,j,i)#Calculate for i
        else:q+=1;p=s(z,q,p)#Calculate for p
        l=[l,p+i-239][j+q<2]#Sets the last record. Since we read in reverse order, this should be the first one. We've added 4 hours though so remove those again
r=lambda d,e:("","%s: %02d:%02d, "%(d,(e/60)%24,e%60))[e>-1];#Print function, don't print anything when we have no value
p+=[1440,0][p>=l];i+=[1440,0][i>=l];    #Add a day if record is before the last record so we can correctly calculate the order
print("Next "+[r("I",i)+r("P",p),r("P",p)+r("I",i)][p<i][:-2])#print it and remove the last ","

PHP, 228 241 239 227 226 bytes
requires PHP 7
Next<?foreach(explode(", ",$argv[1])as$d){[$m,$h,$i]=explode(":",$d);$x[$m][++$$m]=24+$h+$i/60;}foreach($x as$m=>$d)$r[$m]=$d[$$m-3]?:$d[$$m]-20;sort($r);foreach($r as$m=>$t)$o[]=" $m: ".date("i:s",$t%24*60);echo join(",",$o);

breakdown
Next<?                              // print "Next"
foreach(explode(", ",$argv[1])as$d) // loop through string split by comma+space
{
    [$m,$h,$i]=explode(":",$d);         // separate drug, hours and minutes
    $x[$m][++$$m]=24+$h+$i/60;          // append time to array, track count in ${$m}
}                                       // (i.e. $P for drug "P" etc.)
foreach($x as$m=>$d)                // loop through drugs
    $r[$m]=                             // add time to result
        $d[$$m-3]                           // if more than 3 medications, use $$m-3
            ??$d[$$m]-20                    // else use last medication - 20 hours
    ;
sort($r);                           // sort results by time
foreach($r as$m=>$t)$o[]=" $m: "    // prepare for output: drug name and formatted time:
    .date("i:s",$t%24*60)           // use hrs as mins and mins as secs to avoid TZ problems
;
echo join(",",$o);                  // print

JavaScript (ES6), 246 bytes
s=>s.split`, `.map(s=>(m[s[0]].unshift(t=s.replace(/\d+/,h=>(h=(1+h)%24)>9?h:`0`+h),s),l=l||t.slice(1)),l=0,m={I:[],P:[]})&&`Next `+[].concat(m.I[7]||m.I[0]||[],m.P[7]||m.P[0]||[]).sort((i,p)=>((i=i.slice(1))<l)-((p=p.slice(1))<l)||i>p).join`, `

Explanation:
Looping over each dose, the I and P doses are separated into two arrays. 4 hours is also added to each dose, and those times are saved too. The arrays are populated in reverse to make detecting 8 entries easier. The time 4 hours after the first dose is also saved for use during sorting. At this point each array can be in one of three states:

8 entries, in which case the last entry is the first dose, and the next dose must be 24 hours after this dose (i.e. the same time tomorrow)
2, 4 or 6 entries, in which case the first entry is 4 hours after the last dose, and therefore the time of the next dose
0 entries, in which case we concatentate [], which gets flattened and therefore excluded from the result

Having extracted the next dose times from the two arrays, it remains to sort them into order. This is done by comparing them against the time 4 hours after the first dose. If one of the two times is before this time, this must refer to tomorrow, and that dose comes last. Otherwise, the times are simply compared directly. (Rather inconveniently, the medicine is before the time, so I have to strip it to compare properly.)

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


text:
Sprunge this! Sprunge that!
Your task is to create a program or function that creates a paste on sprunge.us. Your program/function must receive the text to sprunge from your language's usual input mechanism, such as standard in; or in the case of a function, it can be a string or whatever makes the most sense to you. Your program will POST the text from input to http://sprunge.us/ as multipart/form-data with the form field name of sprunge. Finally, your program will output/return the URL sent back in the reply from the POST.
This is a code golf, so shortest answer (in bytes) wins.
Here is an example solution using bash and curl taken directly from the sprunge.us website. Feel free to use it in your own golf:
curl -F 'sprunge=<-' http://sprunge.us

Which returns the URL to the paste, which looks like http://sprunge.us/aXZI, where the aXZI is the ID of the sprunge.
This is my first code golfing challenge, please let me know if this is too easy or not creative enough

So, you're not allowed to write a function? Nice challenge, by the way.

Correct, it must be a complete program. Thanks by the way. I have a feeling there might not be much room for improvement from the curl example... I could make this a popularity contest if that's the case.

sprunge seems to be down (503)?

Bummer! :( Maybe I should remake this question to use ptpb.pw...

@devRicher looks like it's back up, sorry about that. I have no control over sprunge.us.

Why can't we write a function?

And I doubt anybody will improve on that curl code. (though if I've golfed the code, can I post an answer using the golfed curl code?)

I'm going to revise the question to allow functions & yes you can base your solution off my example.

I agree the example I gave was a bit too concise for a code golf challenge. With any luck, somebody will come up with a curious alterative.

Bash, 29 25 bytes
curl -F sprunge{=\<-,.us}

Thanks to @Score_Under for providing this awesome solution!
Old solution:
curl -Fsprunge=\<- sprunge.us

Quotes around 'sprunge=<-' are unnecessary, as long as the < is escaped.
EDIT: Interestingly, this alternative way has the exact same length:
a=sprunge
curl -F$a=\<- $a.us

Can be shorter with careful use of brace expansion: curl -F sprunge{=\<-,.us}

@Score_Under Thanks! updated

@Markasoftware The space between F and s is important.

Bash, 30 bytes
curl -F'sprunge=<-' sprunge.us

Just removed the unneeded space in -F 'sprunge=<-' and the http:// from the sprunge.us url.  OP gave me explicit permission to golf his reference solution.

HTML, 88 bytes
<form action="http:sprunge.us" method="POST"><textarea></textarea><button type="submit">

To test this easily, prepend data:text/html, to the code and paste it into your address bar (works for me on chrome).
Full (easily) testable code:
data:text/html,<form action="http:sprunge.us" method="POST"><textarea></textarea><button type="submit">

You ought to be able to replace http: with //.

@Jordan not for me? I think that looks for a file, not a http:// address.

//sprunge.us is a protocol-relative URL, so if it appears on an HTTPS site it'll resolve to https://sprunge.us and if it appears on an HTTP site it'll resolve to http://sprunge.us, so it might not work if you're trying it on an HTTPS site and sprunge.us only works with HTTP. Barring that, I dunno, and I'm not at a computer so it's impractical for me to test. Sorry!

@Jordan it doesn't work, that's all I know.


text:
Is it a Mersenne Prime?

A number is a Mersenne Prime if it is both prime and can be written in the form 2n-1, where n is a positive integer.

Your task is to, given any positive integer, determine whether or not it is a Mersenne prime. You may submit either a function which returns a truthy/falsy value, or a full program which performs IO.
Rules:

As this is code-golf, you should aim to do this in the shortest byte count possible. Builtins are allowed.
Standard golfing loopholes apply - you cannot read the Mersenne primes from external files, or hardcode them into your program.
Your program should work for values within your language's standard integer size.

Test Cases
For reference, a list of (known) Mersenne Primes can be found here. Some handy test cases are:
2  -> False
1  -> False
20 -> False
51 -> False
63 -> False

3    -> True
31   -> True
8191 -> True

Merry Christmas, everybody! Have a great holiday, whatever you celebrate :)

Related: 1, 2

If I could I'd vote this as a dupe of the isprime challenge, as it doesn't really add anything new.

@flawr They are very similar - but for this challenge, there is less likely to be a builtin and there are lots of interesting approaches to determining whether a number is representable as 2^n-1

I believe the definition of a Mersenne number also mandates that n be prime (a condition that has also been proven necessary, but not sufficient, for (2^n)-1 to be prime.)

@SuperJedi224 n is always prime, but knowing that changes nothing, the definition is still correct.

OP, must the code be able to give a correct answer with a probability of 1? i.e Always be correct 100% of the time?

@TheBitByte Yes - if you're implementing some probability-based algorithm which doesn't work 100% of the time, you can still post it, but it wouldn't be competing :)

Jelly, 5 bytes
&‘<ÆP

Try it online!
How it works
&‘<ÆP  Main link. Argument: x

 ‘     Yield x+1.
&      Take the bitwise AND of x and x+1.
       This yields 0 iff x is a Mersenne number, i.e., iff x+1 is a power of 2.
   ÆP  Yield 1 if x is a prime, 0 if not.
  <    Compare the results to both sides,
       This yields 1 iff x is both a Mersenne number and a prime.

Same issue as Adnan's answer. See https://mothereff.in/byte-counter

@KellyLowder That byte counter uses UTF-8. Both Jelly and 05AB1E use single byte character sets.

05AB1E, 5 bytes
A positive number in the form 2n - 1 in binary only consists of 1's.
Code:
b`¹pP

Explanation:
b`      # Push each digit of the binary representation of the number onto the stack
  ¹p    # Check if the input is prime
    P   # Take the product of all these digits

Uses the CP-1252 encoding. Try it online! or Verify all test cases.

I wondered how long until someone used that trick :)

¹ takes 2 bytes, so this is 6.

@KellyLowder In UTF-8, yes. However, 05AB1E uses the CP-1252 encoding rather than the UTF-8 encoding.

p*bW seems to work for 4 bytes

Python, 45 bytes
lambda n:-~n&n<all(n%i for i in range(2,n))<n

Try it online!
How it works
The three terms of the chained comparison
-~n&n<all(n%i for i in range(2,n))<n

do the following:

-~n&n computes the bitwise AND of n + 1 and n. Since n consists solely of 1 bits if it is a Mersenne number, the bitwise AND will return 0 if (and only if) this is the case.
all(n%i for i in range(2,n)) returns True if and only if n mod i is non-zero for all values of i in [2, …, n - 1], i.e., if and only if n has no positive divisors apart from 1 and n.
In other words, all returns True if and only if n is a composite number, i.e., n is either 1 or a prime.
n is self-explanatory.

The chained comparison returns True if and only if the individual comparisons do the same.

Since all returns either True/1 or False/0, -~n&n<all(n%i for i in range(2,n)) can only return True if -~n&n yields 0 (i.e., if n is a Mersenne number) and all returns True (i.e., if n either 1 or a prime).
The comparison all(n%i for i in range(2,n))<n holds whenever n > 1, but since all returns True if n = 1, it does not hold in this case.

Wow, that's amazing :)

Brachylog, 7 bytes
#p+~^h2

Try it online!
A Brachylog program is basically a sequence of constraints which form a chain: the first constraint is between the input and an anonymous unknown (let's call it A for the purpose of this discussion), the second constraint is between that anonymous unknown and a second anonymous unknown (which we'll call B), and so on. As such, the program breaks down like this:
#p      Input = A, and is prime
+       B = A + 1
~^      B = X to the power Y, C = the list [X, Y]
h       D = the head of list C (= X)
2       D = 2

The only way all these constraints can be satisfied simultaneously is if B is a power of 2, i.e. the input is a power of 2 minus 1, and the input is also prime. (Brachylog uses a constraint solver internally, so the program won't be as inefficient as the evaluation order looks; it'll be aware that C is of the form [2, Y] before it tries to express B as the exponentiation of two numbers.)
Interestingly, #p+~^ almost works, because Mersenne-like primes can only use 2 as the base in non-degenerate cases (proof), but a) it fails for non-Mersenne primes B-1 as they can be expressed as B¹, and b) the existing Brachylog interpreter seems to be confused (going into an infinite, or at least long-duration, loop) by a program that's that poorly constrained. So 7 bytes seems unlikely to be beaten in Brachylog.

I'm impressed! As for the infinite loop problem, this is due to the overloading of predicates. Looking back I think I should not have implemented any overloading for predicates. This also causes problems in things like findall.

Mathematica, 29 26 bytes
Edit: Saved 3 bytes thanks to Martin Ender
PrimeQ@#&&IntegerQ@Log2[#+1]&
PrimeQ@#&&1>BitAnd[#,#+1]&

I suspect this would be faster since the first 42 exponents are hard-coded:
MersennePrimeExponentQ@Log2[#+1]&

PrimeQ@#&&1>BitAnd[#,#+1]&

Mathematica 26 Bytes
PerfectNumberQ[# (#+1)/2]&

See this proof
Works so long as there are no odd perfect numbers, and none are known to exist.

So your answer is not proven to be valid?

I do not think that space is necessary.

@JonathanFrech The formula n(n+1)/2 produces (even) perfect numbers whenever n is a Mersenne prime (Euclid). It appears to be unknown whether an odd perfect number can have the form n(n+1)/2, i.e. be a triangular number. All even perfect numbers are triangular where this n is a Mersenne prime (Euler).

@JeppeStigNielsen The question is if it is valid to use an unknown fact to base one's solution upon.

Perl 6, 29 bytes
{.base(2)~~/^1*$/&&.is-prime}

Try it
Expanded:
{             # bare block lambda with implicit parameter ｢$_｣

  .base(2)    # is its binary representation ( implicit method call on ｢$_｣ )
   ~~
  /^ 1* $/    # made entirely of ｢1｣s

  &&          # and

  .is-prime   # is it prime

}

since Perl 6 has arbitrarily large Ints, it doesn't pad the front of .base(2) with 0s.

Python, 83 82 79 76 73 bytes
def f(m):
 s,n=(m!=3)*4,m>>2
 while-~m&m<n:s,n=(s*s-2)%m,n>>1
 return s<1

Python 2, 71 bytes
def f(m):
 s,n=(m!=3)*4,m/4
 while-~m&m<n:s,n=(s*s-2)%m,n/2
 return s<1

This function implements the Lucas–Lehmer primality test, so while it isn't as short as some of the other Python offerings it's much faster at handling huge inputs.

Here's some test code that runs on Python 2 or Python 3.
from __future__ import print_function

def primes(n):
    """ Return a list of primes < n """
    # From http://stackoverflow.com/a/3035188/4014959
    sieve = [True] * (n//2)
    for i in range(3, int(n**0.5) + 1, 2):
        if sieve[i//2]:
            sieve[i*i//2::i] = [False] * ((n - i*i - 1) // (2*i) + 1)
    return [2] + [2*i + 1 for i in range(1, n//2) if sieve[i]]

def lucas_lehmer_old(p):
    m = (1 << p) - 1
    s = 4
    for i in range(p - 2):
        s = (s * s - 2) % m
    return s == 0 and m or 0

# much faster
def lucas_lehmer(p):
    m = (1 << p) - 1
    s = 4
    for i in range(p - 2):
        s = s * s - 2
        while s > m:
            s = (s & m) + (s >> p)
    return s == 0 or s == m and m or 0

def f(m):
 s,n=(m!=3)*4,m>>2
 while-~m&m<n:s,n=(s*s-2)%m,n>>1
 return s<1

# Make a list of some Mersenne primes
a = [3]
for p in primes(608):
    m = lucas_lehmer(p)
    if m:
        print(p, m)
        a.append(m)
print()

# Test that `f` works on all the numbers in `a`
print(all(map(f, a)))

# Test `f` on numbers that may not be Mersenne primes
for i in range(1, 525000):
    u = f(i)
    v = i in a
    if u or v:
        print(i, u, v)
    if u != v:
        print('Error:', i, u, v)

output
3 7
5 31
7 127
13 8191
17 131071
19 524287
31 2147483647
61 2305843009213693951
89 618970019642690137449562111
107 162259276829213363391578010288127
127 170141183460469231731687303715884105727
521 6864797660130609714981900799081393217269435300143305409394463459185543183397656052122559640661454554977296311391480858037121987999716643812574028291115057151
607 531137992816767098689588206552468627329593117727031923199444138200403559860852242739162502265229285668889329486246501015346579337652707239409519978766587351943831270835393219031728127

True
3 True True
7 True True
31 True True
127 True True
8191 True True
131071 True True
524287 True True

FWIW, here's a slightly more efficient version of f that doesn't re-test m on every loop:
def f(m):
 s,n=m!=3and 4,m>>2
 if-~m&m<1:
  while n:
   s=(s*s-2)%m
   n>>=1
 return s<1

You can write the while loop all on one line (no need for a newline and indent)

@FlipTack D'oh! Thankyou! I really don't know why I missed that... And I just noticed I can shave off a couple more bytes by reverting to Python 2.

R, 41 40 bytes
matlab::isprime(x<-scan())&!log2(x+1)%%1

Oddly enough the builtin in R mersenne takes n as argument, not 2^n-1.
This takes x from STDIN, checks if it is prime using the matlab package and checks if the 2-log of x+1 is a whole number by taking mod 1 and checking for 'not zero-ness'.
Also, if you use the mersenne builtin, it ends up being slightly shorter, but feels like cheating:
numbers::mersenne(log2(scan()+1))

Saved 1 byte thanks to @Billywob

Posted a similar answer but I deleted it now. May i suggest matlab::isprime to save one byte. Also you have to use <- for in-function assignment.

@billywob Just noticed aswell that matlab::isprime was 1 byte shorter. (got a 1 second peak at your solution).

You can also use log2(x+1) instead log(x+1,2).

Actually, 9 bytes
;├╔'1=@p*

Try it online!
Explanation:
Since every number of the form 2n-1 has all 1's in its binary representation, a Mersenne prime can be identified as a prime number with that quality.
;├╔'1=@p*
 ├╔'1=     only unique binary digit is 1
        *  and
;     @p   is prime

Pyke, 10 bytes
_PQb2+}\1q

Try it here!
_P         -    is_prime(input)
     +     -   ^ + V
  Qb2      -    base_2(input)
      }    -  uniquify(^)
       \1q - ^ == "1"

Jelly, 5 bytes
Alternate approach to @Dennis' existing 5-byte Jelly answer:
B;ÆPP

Try it online!
How it works:
B      Returns the binary representation of the input as a list [1, 0, 1, 1, ...]
 ;     And attach to this list
  ÆP   a 1 if the input is a prime, 0 otherwise
    P  Calculates the product of this list of 1's and 0's

Since a Mersenne Prime is one less than a power of 2, its binary representation
is excusively 1's. The output therefor is 1 for Mersenne primes, and 0 in all other cases .

Ceylon, 66 bytes
Boolean m(Integer c)=>c>2&&c.and(c+1)<1&&!(2:c-2).any((d)=>c%d<1);

Formatted (and commented):
// Check whether a (positive integer) number is a mersenne prime number.
//
// Question:  http://codegolf.stackexchange.com/q/104508/2338
// My Answer: http://codegolf.stackexchange.com/a/104805/2338

Boolean m(Integer c) =>
        // check whether c+1 is a power of two
        c.and(c+1)<1 &&
        // the standard primality check by trial division
         !(2 : c-2).any((d) => c%d < 1) &&
        // we need to exclude 1, which is unfortunately
        // matched by both criteria above, but is no prime.
        c>1;

With cheating (hardcoding the results in the range of Ceylon's Integer), we can get a byte shorter (65):
Boolean h(Integer c) =>
        c.and(c+1)<1 && #20000000800a20ac.and(c+1)>0;

(It looks like the syntax highlighter misunderstands Ceylon's hex numerals as start-of-comment.)
If an anonymous function is okay, this one is 49 bytes:
[2,3,5,7,13,17,19,31,61].map((p)=>2^p-1).contains

Wolfram Language (Mathematica), 23 bytes
PrimeQ[BitAnd[#,#+2]#]&

Try it online!
1 is handled correctly because PrimeQ[BitAnd[1,1+2]*1] == PrimeQ@1 == False. Otherwise, for BitAnd[#,#+2]# to be prime, we need that # is prime and BitAnd[#,#+2] == 1, which happens when # is a Mersenne number.

Nicely done! As someone who's never used Mathematica, however, your TIO code was confusing at first. Then I realized you're comparing your function against ngenisis's previous tied record holder. I think it'd be better just to show the function's output and maybe have a second link comparing it to the other solution(s).

Regex (ECMAScript), 42 31 bytes
^(?!(xx+)\1+$)(x(x*)(?=\3$))+x$
^
(?!(xx+)\1+$)      # Assert that N is prime or 0 or 1.
(x(x*)(?=\3$))+x$  # Assert that N is a power of 2 minus 1 and is >= 3.
                   # The >=3 part of this prevents the match of 0 and 1.

Try it online!
Edit: Down to 31 bytes thanks to Neil.
The basic "is a power of 2 minus 1" test is ^(x(x*)(?=\2$))*$. This works by looping the operation "subtract 1, then divide evenly by 2" until it can be done no further, then asserting that the result is zero. This can be modified to match only numbers ≥1 by changing the last * to a +, forcing the loop to iterate at least once. Inserting an x before the last $ further modifies it to match only numbers ≥3 by asserting that the final result after looping at least once is 1.
The related "is a power of 2" test is ^((x+)(?=\2$))*x$. There is also a shorthand for matching powers of 2 minus 2, discovered by Grimmy: ^((x+)(?=\2$)x)*$. All three of these regexes are of the same length.
Alternative 31 byte version, by Grimmy:
^(?!(xx+)\1+$|((xx)+)(\2x)*$)xx
Try it online!
# Match Mersenne primes in the domain ^x*$
^                   # N = input number
(?!                 # "(?!p|q)" is equivalent to "(?!p)(?!q)"; evaluate the
                    # logical AND of the following negative lookaheads:
    (xx+)\1+$       # Assert that N is prime or 0 or 1
|
    ((xx)+)(\2x)*$  # Assert that N is a power of 2 minus 1; this is based
                    # on "(?!(x(xx)+)\1*$)" which matches powers of 2.
)
xx                  # Assert that N >= 2, to prevent the unwanted match of
                    # 0 and 1 by both of the negative lookahead statements.

Save 11 bytes by checking directly for a number 1 less than a power of 2: Try it online!

@Neil Thank you very much! I wish I'd thought of that, but then, this is exactly the kind of thing I wanted to happen!

Actually thinking about it would x(x+)(?=\3$) be slightly more efficient?

Yep, you're absolutely right.

Regex (ECMAScript), 29 bytes
^(?!(xx+|(x(x))+)(\1\3)+$)xxx

Try it online!
Inspired by Grimy in chat
The regex asserts that the input is greater than 3, and that it is neither of the form: (xx+)\1+ or ((xx)+)(\1x)+.
The first matches composite numbers.
The second matches a number that is 1 less than a multiple of some odd number greater than 2.
The first will not match prime numbers, or 0 or 1.
The second will not match numbers of the form \$2^n-1\$, or numbers that are 1 less than an odd prime.
Since 2 is the only prime that is 1 less than an odd prime, the negative lookahead, together with the assertion that the input is greater than 3, will match only mersenne primes.

Ruby, 47 bytes
->b{!("%b"%(b/2)=~/0/||(2...b).find{|a|b%a<1})}

Python 3, 68 bytes
a=int(input());print(a&-~a<1and a>1and all(a%b for b in range(2,a)))

Try it here
Python 2, 63 bytes
a=input();print(a&-~a<1)and a>1and all(a%b for b in range(2,a))

Try it here

Thanks for suggestion Jonathan

Open to any suggestions for reducing the bytecount.

1 and ~> 1and.

Julia, 26 bytes
n->isprime(n)&&ispow2(n+1)

Python, 65 bytes
f=lambda n,i=3:(n^i)-all(n%i for i in range(2,n))<0 or f(n,-~i|i)

Outputs via Exit Code. Recursion Error for False. No error for True.
How it works
Since 2^n-1 in binary is made entirely from 1's, the next 2^n-1 number can be generated by number|number+1.
This function uses this by recursively going through each 2^n-1number checking to see if it's a prime number and eqaul to the input. If the number is not a mersenne prime, python will eventually throw an error as the maximum recursion depth would have been exceeded.

If I am not mistaken, <0 ~> 0>.

Pushy, 7 bytes
oBoIpP#

Try it online!
This takes advantage of the fact that mersenne numbers have only ones in their binary representation:
oB      \ Pop input, push its binary digits.
  oI    \ Re-push the input
    p   \ Test its primality (0/1)
     P# \ Print the product of the stack

The stack product will only be 1 if the number has no zeroes in its binary representation, and its primality is True.

Pyth, 8 bytes
&.AjQ2P_

Verify all the test cases.
Pyth, 8 bytes
<.&QhQP_

Verify all the test cases.

How?
Code Breakdown #1
&.AjQ2P_    Full program with implicit input.

      P_    Is Prime?
   jQ2      Convert the input to binary as a list of digits.
 .A         All the elements are truthy (i.e. all are 1).
&           Logical AND.
            Output implicitly.

How does that work?
A number of the form 2n - 1 always contains 1 only when written in binary. Hence, we test if all its binary digits are 1 and if it is prime.
Code Breakdown #2
<.&QhQP_    Full program with implicit input.

      P_    Is Prime?
    hQ      Input + 1.
 .&Q        Bitwise AND between the input and ^.
<           Is smaller than? I.e. The bitwise AND results in 0 and the primality test results in 1.
            Output implicitly.

How does that work?
This tests if the input + 1 is a power of two (i.e. if it is a Mersenne number), and then performs the primality test. In Python, bool is a subclass of int, so truthy is treated as 1 and falsy is treated as 0. To avoid checking explicitly that one is 0 and the other is 1, we compare their values using < (since we only have 1 such case).

Java 8, 53 52 49 bytes
n->{int i=1;for(;n%++i>0;);return(n&n+1|i^n)==0;}

Bug-fixed and golfed by 4 bytes thanks to @Nevay.
Explanation:
Try it here.
n->{                // Method with integer parameter and boolean return-type
  int i=1;          //  Temp integer `i`, starting at 1
  for(;n%++i>0;);   //  Loop and increase `i` as long as `n` is divisible by `i`
  return(n&n+1|i^n) //  Then return if `n` bitwise-AND `n+1` bitwise-OR `i` bitwise-XOR `n`
          ==0;      //  is exactly 0
}                   // End of method

The current solution returns true for every prime >2, not only for Mersenne primes, 56 bytes: n->{for(int i=2;i<n;n&=-n%i++>>-1);return(n&n+1)<1&n>2;}

52 bytes: n->{int i=1;for(;++i<n&n%i>0;);return(n&n+1|i^n)<1;}

@Nevay Thanks.. And not sure why the test cases didn't include any primes that aren't mersenne primes.. Added them myself, and you were indeed right.

49 bytes: n->{int i=1;for(;n%++i>0;);return(n&n+1|i^n)==0;}

Japt, 6 bytes
¢¬×&Uj

Run it or Run all test cases

Very nice :) You could replace logical © with bitwise & for consistent output, if you want.

Prolog (SWI), 48 bytes
Y+X:-X=<Y;X mod Y>0,Y+1+X.
\X:-X>1,2+X,X+1/\X<1.

Try it online!
-7 thanks to Jo King

Vyxal, 6 bytes
æ[›¨²c

Try it Online!
If N is prime, check if n+1 is a power of 2.
Vyxal, 5 bytes
æ⁰bJΠ

Try it Online!
Port of the Jelly 5 byte answer.

Python, 93 Bytes
def f(a):
 for b in range(a):
  if(a+1==2**b and not[i for i in range(2,a)if a%i<1]):return 1

This code would work in both Python 2 and Python 3 so I have not specified a version.

Racket 76 bytes
(define(g m)(for/or((i m))(= m(-(expt 2 i)1))))(if(and(prime? n)(g n))#t #f)

Ungolfed:
(require math)
(define(f n)
  (define (ispowerminus1 m)
    (for/or ((i m))
      (= m (-(expt 2 i)1))))
  (if (and (prime? n)
           (ispowerminus1 n))
      #t #f))

Testing:
(f 1)
(f 2)
(f 20)
(f 51)
(f 63)
(f 3)
(f 31)
(f 8191)

Output:
#f
#f
#f
#f
#f
#t
#t
#t

PHP, 53 bytes
for($i=$n=$argv[1];--$i&&$n%$i;);echo!($i-1|$n+1&$n);

takes command line argument; prints 1 for Mersenne prime, empty string else.
Run with -r.
breakdown
for($i=$n=$argv[1];--$i&&$n%$i;);   // loop $i down from $n-1 until $i divides $n
                        // If $n is prime, loop ends with $i=1. ($n=1 -> $i=0)
echo!($i-1|$n+1&$n);    // If $i!=1, $n is not prime. If ($n+1&$n)>0, $n is not Mersenne.
                        // If either $i-1 or $n+1&$n is truthy, the negation will be false.

C, 94 bytes
g(n,i){return--i?g(2*n,i):n;}n,r;f(x){for(n=r=1;++n<x;)r=x%n?x^g(2,n)-1?r:r|2:r&2;return r>2;}

Returns 1 if the number is a Mersenne Prime, 0 otherwise.

Suggest ~x+g(2,n) instead of x^g(2,n)-1

Scala,  59 Bytes
def f(t:BigInt)=t.isProbablePrime(t.bitLength*9)&(1+t)%2==0

This function requires the input to be a BigInt.  You can easily convert a string "162259276829213363391578010288127" (2**107-1 is a Mersenne prime) into BigInt by doing BigInt("162259276829213363391578010288127").
It might go wrong as the name of isProbablePrime() method suggests.  But the probability is not more than 0.5^(t.bigLength)*9.
Standalone script version is 72 bytes long.
val t=BigInt(args(0));print(t.isProbablePrime(t.bitLength*9)&(1+t)%2==0)

Assume we save it as "t.scala", then then program can be run as
>scala t.scala 162259276829213363391578010288127
>true

You can remove the Probable from isProbablePrime if Scala has an isPrime function.

Perl 5, 53 bytes
52 bytes of code + 1 for -p
$f=0|sqrt;1while$_%$f--;$_=!$f*(sprintf'%b',$_)!~/0/

Try it online!

According to meta consensus, the -p is classified as another programming language, and hence doesn't count in your bytecount.

J, 16 bytes
*./(#:,1&=@#@q:)
This solution consists of a fork and then a reduce, returns a 1 if true and 0 if false.
The left side of the fork #: returns the binary expansion of the input; the right side 1&=@#@q: produces the prime factors, then tests whether the resulting array contains only a single item (so, whether or not the input is prime). Finally, the middle part of the fork , contains the two results. The result of the fork is reduced with the and operator (*.). Since the 1 less a power of two's binary expansion will only contain ones, we can pretend the binary expansion is actually an array of booleans.

JavaScript (Node.js), 57 bytes
n=>!(n&n+1||(g=(m,q)=>m>3?g(m>>1,(q*q-2)%n):n-3&&q)(n,4))

Try it online!
Implements Lucas-Lehmer primality test. Works for n<2**26.5
(FINALLY NATIVE BIGINT SUPPORT IN JS IN 2018. HAIL V8)
For arbitrarily sized integers, try n=>!(n&n+1n||(g=(m,q)=>m>3n?g(m/2n,(q*q-2n)%n):n-3n&&q)(n,4n)) for 62 bytes. Only works in Chrome 67+ and Node.js 10.4.1+ because of BigInt support. Have a try on 2**4423-1!

APL (Dyalog Classic), 21 bytes
1∧.=1∘≠,2∘⊥⍣¯1,¯1↓⊢∨⍳

Verify test cases
Explanation:
Similar method to others here. Prime test + binary representation of Mersenne number being all 1s.

¯1↓⊢∨⍳ is a prime test. The length of the result depends on the size of the number but if the number is prime every element of the result list will be 1.
(the exception is 1 which annoyingly returns empty list) Catenated with , to....
2∘⊥⍣¯1 is the easiest way to encode into binary in Dyalog, by inverting the decode-from-binary operation (yeah i know right), catenated to.....
1∘≠ which is there to catch the corner case that the above tests can't tell that 1 isn't a Mersenne prime. (Prime test returns empty list, binary encode results in 1, so result of concatenations contains only 1s)
If the list resulting from the above operations contains only 1s, the result is a Mersenne prime. 1∧.= checks that all elements are 1.

APL(NARS), chars 20, bytes 40
{0π⍵×∧/⍵⊤⍨2⍴⍨1+⌊2⍟⍵}

0π return true [1] if its argument is prime else return false [0], test:
  f←{0π⍵×∧/⍵⊤⍨2⍴⍨1+⌊2⍟⍵}
  f¨2 1 20 51 63
0 0 0 0 0
  f¨3 31 8191
1 1 1

Husk, 8 bytes
§&o£İ2→ṗ

Try it online!

Thunno 2 M, 3 bytes
P×ḃ

Try it online!
Explanation
     # Implicit input

P    # Is the input prime?
     #   i.e.  1 if it's prime,
     #         0 otherwise

 ×   # Multiply by the input
     #   i.e.  (input) if it's prime,
     #         0 otherwise

  ḃ  # Convert to binary
     #   i.e.  a string of 1s if it's a Mersenne prime,
     #         a string including 0s if it's prime but not a Mersenne prime
     #         0 if it's not prime

     #   i.e   a string of 1s if it's a Mersenne prime,
     #         a string including 0s if it's not a Mersenne prime

     # M flag - take the minimum
     #   i.e.  1 if it's a Mersenne prime
     #         0 otherwise

     # Implicit output

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