Mistři v programování na #hovnokod

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,

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,


Anonymous,

parsovani barvy a casu jako za krale Klacka

rgba = function(color) {
    var m;
    if (String(color).match(/^\#\w{8}/)) {
        m = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})(\d+)$/i.exec(color);
        return 'rgba(' + parseInt(m[1], 16) + ', ' + parseInt(m[2], 16) + ', ' + parseInt(m[3], 16) + ', ' + (parseInt(m[4], 10) / 100) + ')';
    }

    return color;
};

getTime = function(str, offset) {
    var t, p;

    if (!str) {
        return null;
    }

    if (str.match(/s$/) || str.match(/^\d+\.\d+$/)) {
        t = parseFloat(str) * 1000;

    } else {
        p = String(str).split(/\,|\.|\:/);
        t = Math.round(((parseInt(p[0], 10) * 3600000) + (parseInt(p[1], 10) * 60000) + (parseInt(p[2], 10) * 1000) + parseInt(p[3], 10)));
    }

    if (offset) {
        t += offset;
    }

    return t;
};

Anonymous,

Bylo mi divný, že mi v editoru něco žere písmenka z některých slov....

int n = text.length();
for (int i = 0; i < n; i++) {	    
char ch = text.charAt(i);
            if (Character.isWhitespace(i)) {
                continue;
            }
}

Anonymous,