- 1
- 2
- 3
- 4
- 5
if (['text'].indexOf(data[a]['input']) === 'date') {
data[a]['value'][f].subscribe(function (nv) {
self.pollChanges();
})
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+144
if (['text'].indexOf(data[a]['input']) === 'date') {
data[a]['value'][f].subscribe(function (nv) {
self.pollChanges();
})
}
+144
catch (Exception ex)
{
status = ex.Message;
throw ex;
}
−241
def __repr__(self):
# почему здесь бесконечная рекурсия?
return repr(self.__repr__)
+57
#include <iostream>
#include <stdexcept>
template<std::size_t N>
static int constexpr date_component(const char (&s)[N], int i, bool last, int max) {
return
(i + 2 + (last ? 0 : 1) >= N)
? throw std::logic_error("Too short date string") :
(!last && s[i + 2] != ':')
? throw std::logic_error("Cannot find delimiter") :
(s[i] < '0' || s[i] > '9' || s[i + 1] < '0' || s[i + 1] > '9')
? throw std::logic_error("Not a number") :
((s[i] - '0') * 10 + (s[i + 1] - '0') > max)
? throw std::logic_error("Too large number") :
(s[i] - '0') * 10 + (s[i + 1] - '0');
}
struct time {
int hour; int minute; int second;
template<std::size_t N>
constexpr time(const char (&datestr)[N]) :
hour(date_component(datestr, 0, false, 24)),
minute(date_component(datestr, 3, false, 60)),
second(date_component(datestr, 6, true, 60))
{}
};
struct time constexpr midnight("00:00:00");
struct time constexpr afternoon("12:00:00");
int main(int argc, char* argv[]) {
std::cout << "Midnight hour is " << midnight.hour << std::endl;
std::cout << "Afternoon hour is " << afternoon.hour << std::endl;
}
C++ и даты времени компиляции
+164
function addnews($str1="", $str2="", $str3="", $str4="", $str5=""){
$num = 0;
$done = 0;
while ($done == 0){
$num++;
$s = "";
if ($num<10000000) {$s="0".$s;}
if ($num<1000000) {$s="0".$s;}
if ($num<100000) {$s="0".$s;}
if ($num<10000) {$s="0".$s;}
if ($num<1000) {$s="0".$s;}
if ($num<100) {$s="0".$s;}
if ($num<10) {$s="0".$s;}
$done = 1;
if (file_exists("news/".$s.$num.".txt")){$done=0;}
}
$fh1 =fopen("news/".$s.$num.".txt","w");
fwrite($fh1, $str1."\r\n");
fwrite($fh1, $str2."\r\n");
fwrite($fh1, $str3."\r\n");
fwrite($fh1, $str4."\r\n");
fwrite($fh1, $str5);
fclose($fh1);
}
Предложили доработать корпоративную тикет-систему. Движок абсолютно всё хранит в txt-файлах. Да, и пароли пользователей тоже - в открытом виде. БД? Нет, не слышали :(
Но это еще не так страшно...
+54
void Game::initialize()
{
if (SDL_Init(SDL_INIT_VIDEO))
exit(1);
window = new Window("Game", 640, 480);
try
{
window->create();
}
catch (const Exception& exception)
{
std::cout << exception.getError() << '\n';
delete window;
exit(1);
}
canvas = new Canvas();
try
{
canvas->initialize(window->getWindow());
}
catch (const Exception& exception)
{
std::cout << exception.getError() << '\n';
delete canvas;
exit(1);
}
}
+157
function getMinQueueOrdering()
{
$sql="SELECT MAX(ordering)
FROM priceloaddata_queue";
.........
}
нет слов.
+64
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
public class PolynomialParser {
public Polynomial parse(String rawPolynomial) {
String source = normalizeSourceString(rawPolynomial);
Map<Integer, Integer> result = new HashMap<>();
StringTokenizer tokenizer = new StringTokenizer(source, "[+-]", true);
boolean isCurrentNegative = false;
int currentDegree;
int currentCoefficient;
while (tokenizer.hasMoreTokens()) {
String currentToken = tokenizer.nextToken();
if ("-".equals(currentToken)) {
isCurrentNegative = true;
} else if ("+".equals(currentToken)) {
isCurrentNegative = false;
} else {
if (currentToken.contains("x")) {
if (currentToken.contains("^")) {
String[] tmp = currentToken.split("x\\^");
currentDegree = Integer.parseInt(tmp[1]);
int draftCoefficient = Integer.parseInt(tmp[0]);
currentCoefficient = (isCurrentNegative) ? - draftCoefficient : draftCoefficient;
} else {
currentDegree = 1;
String[] tmp = currentToken.split("x");
int draftCoefficient = (tmp.length == 0) ? 1 : Integer.parseInt(tmp[0]);
currentCoefficient = (isCurrentNegative) ? - draftCoefficient : draftCoefficient;
}
} else {
currentDegree = 0;
int draftCoefficient = Integer.parseInt(currentToken);
currentCoefficient = (isCurrentNegative) ? - draftCoefficient : draftCoefficient;
}
result.put(currentDegree, currentCoefficient);
}
}
return new Polynomial(result);
}
private String normalizeSourceString(String source) {
String result = source.replaceAll("\\s+","");
return result.toLowerCase();
}
}
Из сегодняшнего. Парсинг многочленов.
+158
// classes.php
return [
'yii\base\Action' => YII2_PATH . '/base/Action.php',
'yii\base\ActionEvent' => YII2_PATH . '/base/ActionEvent.php',
'yii\base\ActionFilter' => YII2_PATH . '/base/ActionFilter.php',
// еще порядка трех сотен классов
];
https://github.com/yiisoft/yii2/blob/d2b864da84a68d56a96709479af78d203f050451/framework/classes.php
осень 2014, использующий composer модный фреймворк, "requires PHP 5.4 and embraces the best practices and protocols found in modern Web application development", и, конечно, ебаный стыд.
+84
List selection = new ArrayList((s != null) ? s : new ArrayList());
Больше мусора для бога сборщика мусора!