> const today = new Date(2016, 7, 7)
undefined
> const tomorrow = new Date(2016, 7, 8)
undefined
> tomorrow >= today
true
> today <= tomorrow
true
> today == tomorrow
false
By winek, 2016-05-30 16:08:25
const allowed = {
    '1': true,
    '2': true,
    '3': true,
    '4': true,
    '5': true,
    '6': true,
    '7': true,
    '8': true,
    '9': true,
    '0': true,
    'ArrowLeft': true,
    'ArrowDown': true,
    'ArrowRight': true,
    'ArrowUp': true,
    'Backspace': true,
    '.': true,
}

const isValidInput = allowed[key]
By Anonymous, 2019-07-26 16:34:12
def __getCurlOutput (self, url, **kwargs):
	curlcmd = "curl {0}".format(url)

	for key, value in kwargs.items():
		key = key.lower()

		if key == "origin":
			curlcmd += " -H 'Origin: {0}'".format(value)
		elif key == "contenttype":
			curlcmd += " -H 'Content-Type: {0}'".format(value)
		elif key == "referer":
			curlcmd += " -H 'Referer: {0}'".format(value)
		elif key == "cookie":
			curlcmd += " -H 'Cookie: {0}'".format(value)
		elif key == "data":
			curlcmd += " --data '{0}'".format(value)
		elif key == "verbose":
			if value == True:
				curlcmd += " --verbose"
			else:
				curlcmd += " --silent"
		elif key == "output":
			curlcmd += " --output {0}".format(value)
		else:
			print "Unsupported key: {0}".format(key)

	curlcmd += " 2>&1"

	print curlcmd

	curlout = subprocess.check_output(curlcmd,shell=True)

	return curlout
By AnonimaPitoni, 2018-12-04 19:22:34
if (!String.prototype.replaceLast) {
        String.prototype.replaceLast = function(find, replace) {
            String.prototype.replaceLast = function (what, replacement) {
                var pcs = this.split(what);
                var lastPc = pcs.pop();
                return pcs.join(what) + replacement + lastPc;
            };
        };
    }

Prototypes are super buggy anyway, I should rewrite that as a pure function.

By Anonymous, 2017-12-12 18:21:40
const Discord = require("discord.js");
const bot = new Discord.Client();
const TOKEN = "NOPE"
var color = require('chalk');
var fs = require('fs');

bot.on("ready", function(message) {
    console.log(color.green("Online"))
})
bot.on("message", function(message){
    console.log("Channel:" + color.blue(message.channel) + " " + "Author:" + color.blue(message.author) + " " + "Message:" + color.blue(message.content))
    if (message.content.includes("uranium") || message.content == "Uranium" || message.content == "uranium" || message.content.includes("uranium")) {
        console.log(color.black.yellow("Message Flagged As Suspicous"))
        console.log(color.black.yellow("Contains: Uranium"))
        console.log(color.black.bgYellow("Message:" + message.content))
        console.log(color.black.bgYellow("Message Id:" + message.id))
        console.log(color.black.bgYellow("Author Id:" + message.author.id))
        console.log(color.black.bgYellow("Channel Id:" + message.channel.id))
        console.log(color.yellow("Severity:" + "1"))
        var alertsev1 =  `Message + Id: + ${message.id} + | + Author + Id: + ${message.author.id} + | + Message + Channel Id: ${message.channel.id} + | + Message: + ${message.content}` 
        fs.writeFile('alerts.txt', `${alertsev2}`)
    }
    if (message.content.includes("raid") || message.content.includes("Raid")) {
        console.log(color.black.red("Message Flagged As Suspicous"))
        console.log(color.black.red("Contains: Raid"))
        console.log(color.black.bgRed("Message:" + message.content))
        console.log(color.black.bgRed("Message Id:" + message.id))
        console.log(color.black.bgRed("Author Id:" + message.author.id))
        console.log(color.black.bgRed("Channel Id:" + message.channel.id))
        console.log(color.black.red("Severity:" + "2"))
        var alertsev2 =  `Message + Id: + ${message.id} + | + Author + Id: + ${message.author.id} + | + Message + Channel Id: ${message.channel.id} + | + Message: + ${message.content}` 
        fs.writeFile('alerts.txt', `${alertsev2}`)
    }
    if (message.content.includes("raid") && message.content.includes("uranium") || message.content.includes("raid") && message.content.includes("Uranium") || message.content.includes("raid") && message.content.includes("uranium") || message.content.includes("Raid") && message.content.includes("uranium") || message.content.includes("Raid")) {
        console.log(color.black.red("Message Flagged As Possible Raid Initiation"))
        console.log(color.black.red("Contains: Raid, Uranium"))
        console.log(color.black.bgRed("Message:" + message.content))
        console.log(color.black.bgRed("Message Id:" + message.id))
        console.log(color.black.bgRed("Author Id:" + message.author.id))
        console.log(color.black.bgRed("Channel Id:" + message.channel.id))
        console.log(color.black.red("Severity:" + "3"))
        var alertsev3 =  `Message + Id: + ${message.id} + | + Author + Id: + ${message.author.id} + | + Message + Channel Id: ${message.channel.id} + | + Message: + ${message.content}` 
        fs.writeFile('alerts.txt', `${alertsev3}`)
    }
})
bot.login(TOKEN)

I'm making a discord message logger but I want to output message.content message.author message.id message.channel.id into one text file everytime a message is sent in the following format: Message ID:(Id here) Message Author: (Author ID here) Channel ID: (Channel ID here) Message: (message here) ive tried with the following code but it printed undefined out into the text document

By JackThePug, 2019-03-16 22:31:03
string AllPDF = "";
int CountPDF = 0;
AllPDF = txtInput.Text;
string[] AllPDF2 = AllPDF.Split(';');
List<string> PDF = new List<string>();
PDF.AddRange(AllPDF2);
while (PDF.Count != CountPDF)
{
    File.Delete(AllPDF2[0 + CountPDF] + ".pdf");
	CountPDF++;
}

I believe, there are so many easier ways to do that

By Anonymous, 2018-03-27 12:15:10
switch (kafkaStreams.state()) {
                case RUNNING: {
                    if (kafkaStreams.state().isRunning()) {
                        countDownLatch.countDown();
                    }
                }
                break;
By Anonymous, 2018-07-05 18:05:59
int var = 0;
int* ptr = &var;
ptr[0] = 5;
std::cout << ptr[0];
By Anonymous, 2015-07-24 23:51:35
$number = int(1);
By Richard Chipper, 2017-12-14 08:22:23
<?php

// This code supposed to find adjacent items of a specific one
// $list is an array of ids
// $itemToSearch is an id that might be in the $list

foreach ($list as $item) {
    next($list);
    if ($item == $itemToSearch) {
        break;
    }
    $previousItem = $item;
}
$nextItem = current($list);

The $list variable is a list of ids, e.g [1, 2, 3, 4, 5] The $itemToSearch is an id that might be in $list

By baueri, 2022-05-31 17:30:21
#266 Java -28
        //JSONObject input;
        
        String givenName = input.get("propName") != null ? (String)input.get("propName") : null;

WHAT DA FUCK ASSHOLES

By Anonymous, 2018-03-15 15:28:55
if(userEndDate.getTime() != null
    && userEndDate.getTime() > today.getTime()
    && endDateFromRequest != null ? endDateFromRequest.getTime() !== userEndDate.getTime() : true){
            
            //some code
     }

for code lovers :D

By Unnamed, 2018-11-30 16:12:08
String zeroPad(int number) {
  return number < 10 ? "0" + number : String.valueOf(number);
}

You could just have done String.format("%02d", number);

By Anonymous, 2022-04-30 10:50:20
<ng-container *ngIf="!errors">
    <div *ngIf="errors" class="no-content-wrapper">
        <esel-components-error [error]="errors"></esel-components-error>
    </div>
</ng-container>

Make your code error prone with effective error handling!

By Anonymous, 2019-10-11 12:49:41
switch ($content) {
    case "vid":
      echo '<iframe width="600" height="450" src="http://www.youtube.com/embed/' . $img . '" frameborder="0" allowfullscreen></iframe>';
      break;
    default:
      if ($height > 0 && $width > 0) {
        echo '<img width="' . $width . '" height="' . $height . '" src="http://szpileczki.com/up/' . $img . '"/>';
      } else {
        if ($kochamto == 1) {
          echo '<img src="http://kocham.to/up/' . $img . '"/>';
        } else {
          echo '<img src="http://szpileczki.com/up/' . $img . '"/>';
        }
      }
      break;
 }

especially if one of them doesn't exist since 2012

By Anonymous, 2016-11-19 14:54:36