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
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
switch (kafkaStreams.state()) {
                case RUNNING: {
                    if (kafkaStreams.state().isRunning()) {
                        countDownLatch.countDown();
                    }
                }
                break;
By Anonymous, 2018-07-05 18:05:59
$number = int(1);
By Richard Chipper, 2017-12-14 08:22:23
export const getUniqueIds = (ids: string[]) => {
  const uniqueIds = new Set<string>();
  return ids.filter((id) => {
    if (!uniqueIds.has(id)) {
      uniqueIds.add(id);
      return true;
    }
    return false;
  });
};
By Anonymous, 2024-01-27 11:22:30
int var = 0;
int* ptr = &var;
ptr[0] = 5;
std::cout << ptr[0];
By Anonymous, 2015-07-24 23:51:35
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 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
from typing import Dict, List

from dataclasses import dataclass
from lbcore.orders import Order, Match


@dataclass
class SideEffect:
    order_id: str = ''
    action: Dict = None
    updates: Dict = None
    matches: List[Match] = None
    order: Order = None
    action_exists: bool = False

    def match(self, price):
        match = self.action.copy()
        match['price'] = price
        return match


class SideEffects(list):
    def add_action(self, order, action_exists=False, **action):
        action['order_id'] = order.id
        se = SideEffect(order=order, action=action,
                        action_exists=action_exists)
        self.append(se)
        return se

    def add_update(self, order_id, **updates):
        se = SideEffect(order_id=order_id, updates=updates)
        self.append(se)
        return se

    def add_trade(self, order, matches):
        se = SideEffect(order=order, matches=matches)
        self.append(se)
        return se
By Anonymous, 2019-07-18 13:24:21
#266 Java -31
        //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 (!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
/*
 *                                                      _____________________________________________________ 
 *                                           ___________↓___↓____________________________________________   |  
 *                                          _↓_________↓|___|________________________________________   |   |
 *                                    ______↓|_________||___|↓___________________________________   |   |   |
 *                               _____↓__↓__||_________||___||_______________________________   |   |   |   |
 *                              _↓__↓_|__|__||_________||___||___________________________   |   |   |   |   |
 *                     _________↓|__|_|__|↓_||_________||___||_______________________   |   |   |   |   |   |
 *                     ↓   ↓    ||  | |  || ||         ||   ||                      |   |   |   |   |   |   |      */
opcId = child.replace(/([.])?(?:((.+)=(.+))|(([a-zA-Z]+)(\d*)))/g, function (match, m1, m2, m3, m4, m5, m6, m7) {
By Michal, 2024-01-18 13:18:02
        int i = 0;
        while (conn == null && i < 116) {
            try {
                Thread.sleep(i < 30 ? 2000 : (i < 40 ? 6000 : (i < 56 ? 30000 : 60000)));
            } catch (Exception e) {
                e.printStackTrace();
            }
            try {
                conn = Server.getConnection();
            } catch (Exception e) {
                //e.printStackTrace();
            }
            i++;
            if ((i < 41 && (i % 5) == 0)
                    || (i > 40 && i < 45)
                    || (i > 44 && i < 56 && (i % 2) == 0)
                    || (i > 55 && ((i - 56) % 3) == 0))
                System.out.print('.');
        }
By Anonymous, 2023-07-30 00:09:39
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iterator>

constexpr int N = 10;

int main() {
    std::vector<int> even;
    std::vector<int> odd;
    
    even.resize(N);
    
    // Fill up the 'even' vector with integers starting from from 1 through 'N'
    std::iota(even.begin(), even.end(), 1);

    // Segregate the odd and even integers from each other
    
    for (auto it = even.begin(); it != even.end(); ++it)
        if (*it % 2 != 0) {
            // If the number is odd, put it in the 'odd' vector
            odd.push_back(*it);
            // Remove the number from the even vector
            even.erase(it);
        }

    // Print the result
    
    std::cout << "Even numbers: ";
    std::copy(even.begin(), even.end(), std::ostream_iterator<int>(std::cout, " "));

    std::cout << "\nOdd numbers: ";
    std::copy(odd.begin(), odd.end(), std::ostream_iterator<int>(std::cout, " "));

    std::cout << '\n';
}

Seems fine to me... C++ couldn't possibly be THAT evil to introduce another nuanced and verbose complexity in there, right?

By cufbox, 2023-12-15 09:38:58