Mistři v programování na #hovnokod

Jak ziskat posledni e-mail? Preci si nacist vsechny z db a vratit prvni.

function getLastEmail($code) {			
    $mails = dibi::fetchAll('SELECT id FROM emails e WHERE e.deleted = 0 AND e.name LIKE %~like~ ORDER BY e.date_entered DESC', $code);

    foreach($mails as $mail) {
        return $mail;
    }
}

Anonymous,

fail fast!

if (inRegulatedEntity == null) {
    throw new NullPointerException();
}

String urn = inRegulatedEntity.getGlobalUrn();

Anonymous,

Trideni v konstantnim case (Scala variant).

import java.util.{Timer,TimerTask}
object SleepSort extends App {
  val timer = new Timer
  def delay(f: () => Unit, n: Long) = {
    timer.schedule(new TimerTask() {
      def run = f()
    }, n)
  }
  def sleepSort(a: Array[Int]) = {
    for (i <- a) delay(() => println(i), i)
  }
  sleepSort(Array(531,112,43,355,911,299,24))
  delay(() => timer.cancel(), 1000)
}

David Strupl,

normalny clovek by to napisal takto... ItemPrices.ForEach(p => p.CompanyId = _userInfoService.CompanyId);

...
ItemPrices.Select(p => p.CompanyId = _userInfoService.CompanyId).ToList();
...

Anonymous,

Verejne dostupny GDPR-ready kod

<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

ini_set('memory_limit', '-1');

include "NotORM.php";
$pdo = new PDO("mysql:dbname=production", "production", "Secr3tPassw0rd");
$db = new NotORM($pdo);
foreach ($db->sales_flat_order() as $order) { // get all applications
    echo "$order[customer_email]<br>"; // print application title
}
//echo 'Hello world';

Anonymous,