- 1
- 2
- 3
if(Math.round(Math.random()*10)==7){
alert('Your name/lastname alredy used! Try other.');
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+154
if(Math.round(Math.random()*10)==7){
alert('Your name/lastname alredy used! Try other.');
}
Валидация форм, чё
+75
if ( !empty($special['catalog']) ) {
if (count($special['catalog'])>0) {
if (count($special['catalog'])>1) {
...
}
}
}
Интересная конструкция...
+72
<?php if ($content): ?>
<?php if($is_page): ?>
<?php print $content; ?>
<?php else: ?>
<?php print $content; ?>
<?php endif?>
<?php endif?>
Где-то, в глубоких кодах проекта (писанном на Drupal 7)
+34
#include "xsmell.hpp"
#include <iostream>
TAG(html, NO_ATTRIBS);
TAG(head, NO_ATTRIBS);
TAG(title, NO_ATTRIBS);
TAG(body, NO_ATTRIBS);
TAG(p, NO_ATTRIBS);
TAG(a, ATTRIB(href));
TAG(img, ATTRIB(src), ATTRIB(alt));
int main()
{
using namespace xsmell;
document doc =
_
<html>_
<head>_
<title>"XSMELL demo"<!title>_
<!head>_
<body>_
<p>"Yesssssssssssssssss!"<!p>_
<img .src("chucknorris.png") .alt("sneezing eyes open")>_ <!img>_
<!body>_
<!html>
_;
std::cout << doc << '\n';
return 0;
}
C++ умеет HTML не хуже этих ваших похапешечек ;)
https://bitbucket.org/edd/xsmell/src
−139
#!/usr/bin/perl -w
use strict;
use warnings;
use diagnostics;
use LWP::Simple;
binmode(STDOUT, ":utf8");
my $url = 'http://govnokod.ru/comments';
my $document = get $url; die "Couldn't get $url" unless defined $document;
$document =~ s/\n/ /g;
$document =~ s/\h+/ /g;
my @arr = ( $document =~ m/(?<=\<strong class="entry-author">)(.*?)(?<=\<a class="answer")/gi );
my $str;
my @sink;
foreach my $val (@arr) {
$val =~ m/(?<=\>)(.*?)(?=\<\/a\>)/i;
$str = "Author: ".$1;
$val =~ m/(?<=published" title\=")(.*?)(?=")/i;
( my $dt, my $tm ) = split('T', $1);
$str = $str . "\nDate: " . $dt;
$str = $str . "\nTime: " . $tm;
$val =~ m/(?<=\<\/abbr\> \<a href\=")(.*?)(?=" name\=)/i;
$str = $str."\nLink: ". $1;
$val =~ m/(?<=\<div class\="entry-comment">)(.*?)(?=\<\/div\>)/i;
$str = $str . "\nComment: " . str_formater($1);
push(@sink, $str);
}
@sink = reverse (@sink);
foreach my $v (@sink) {
print ("\n".("+" x 81)."\n"."$v\n");
}
print ("\n".("+" x 81)."\n\n");
sub str_formater {
my $str = $_[0];
my $res="";
my $cmt_len = 69;
my $cmt_indent = 11;
while (1) {
if (length($str)<=$cmt_len) {
return $res . $str;
}
$res = $res . substr($str,0, $cmt_len) . "\n" . (" " x $cmt_indent);
$str = substr($str, $cmt_len);
}
return $res;
}
exit 0;
Давненько перловку не заваривал...
+70
public static class TrollException extends RuntimeException {
@Override
public String getMessage() {
throw new TrollException();
}
@Override
public String getLocalizedMessage() {
throw new TrollException();
}
@Override
public Throwable getCause() {
throw new TrollException();
}
@Override
public synchronized Throwable initCause(Throwable cause) {
throw new TrollException();
}
@Override
public String toString() {
throw new TrollException();
}
@Override
public void printStackTrace() {
throw new TrollException();
}
@Override
public void printStackTrace(PrintStream s) {
throw new TrollException();
}
@Override
public void printStackTrace(PrintWriter s) {
throw new TrollException();
}
@Override
public synchronized Throwable fillInStackTrace() {
throw new TrollException();
}
@Override
public StackTraceElement[] getStackTrace() {
throw new TrollException();
}
@Override
public void setStackTrace(StackTraceElement[] stackTrace) {
throw new TrollException();
}
}
+47
if ($num_rows2>0) {
$raw2=mysql_fetch_array($sth2, MYSQL_ASSOC);
$desc=$raw2['desc'];
$sector = "$desc";//O-o-o!
}
//далее $desc нигде не используется, равно как и $raw2
//и ещё:
$sid=$raw['id'];
$sector=$raw['sector'];
$selind='';
if ($sector==$sid) { $selind='selected'; }
echo "<option value='$sid' $selind >$sector</option>";
//и так по всему коду
//А ЭТО вместо темплэйта от 30 до 150 include за один раз с огрызками HTML и PHP
<?php
require_once('includes/core.php'); // connection, config
$is_index_page = true; // add this variable to check that we are on default index page (#2907)
require_once('header.php');
require_once('menu.php');
include('homepage.php');
. . .
. . .
require_once('footer.php');
?>
Реальный кусок Хадж-кода. В комплекте более 3500 файлов перекрёстно инклюдящих друг друга. Действительно "Индусский код" оплачивается построчно..., дёшево, долго, сердито.
+55
if($contact == null){
$msg = JText::_('INSERT_CONTACT_DETAILS');
if($contact == null){
$mainframe->redirect('index.php?option=com_xxx&act=Agents',Text::_($msg).$user->name);
}
return;
}
Правильно грят: бережённого бог бережёт :)
+64
<?php
/* File: config.php */
$ea_hot_color = "#F06000";
$ea_fulllocation = "1";
$ea_curconverter = "1";
$ea_show_hits = "1";
$ea_show_created_date = "1";
//и т.д.~300 строк
// ============================
/* File: config.class.php */
class EAConf{
/*
...
*/
function EAConf(){
require('config.php');
$allvars=get_defined_vars();
$names=array_keys($allvars);
foreach($names as $name){
if(substr($name,0,2)=="ea") $this->$name=$allvars[$name];
}
}
/*
...
*/
}
Какая глубина мысли! Смело, нетривиально!
+70
} catch (CacheException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
Привет из Индии